Skip to content
This repository has been archived by the owner on Nov 21, 2022. It is now read-only.

Commit

Permalink
mm/gup: assert that the mmap lock is held in __get_user_pages()
Browse files Browse the repository at this point in the history
After having cleaned up all GUP callers (except for the atomisp staging
driver, which currently gets mmap locking completely wrong [1]) to always
ensure that they hold the mmap lock when calling into GUP (unless the mm
is not yet globally visible), add an assertion to make sure it stays that
way going forward.

[1] https://lore.kernel.org/lkml/CAG48ez3tZAb9JVhw4T5e-i=h2_DUZxfNRTDsagSRCVazNXx5qA@mail.gmail.com/

Link: https://lkml.kernel.org/r/CAG48ez1GM==OnHpS=ghqZNJPn02FCDUEHc7GQmGRMXUD_aKudg@mail.gmail.com
Signed-off-by: Jann Horn <[email protected]>
Reviewed-by: Jason Gunthorpe <[email protected]>
Acked-by: Michel Lespinasse <[email protected]>
Cc: "Eric W . Biederman" <[email protected]>
Cc: John Hubbard <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Sakari Ailus <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Stephen Rothwell <[email protected]>
  • Loading branch information
thejh authored and sfrothwell committed Oct 22, 2020
1 parent ba945a0 commit 6b4eb38
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mm/gup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,8 @@ static long __get_user_pages(struct mm_struct *mm,
struct vm_area_struct *vma = NULL;
struct follow_page_context ctx = { NULL };

mmap_assert_locked(mm);

if (!nr_pages)
return 0;

Expand Down

0 comments on commit 6b4eb38

Please sign in to comment.