summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJann Horn <jannh@google.com>2020-11-24 16:45:20 +1100
committerStephen Rothwell <sfr@canb.auug.org.au>2020-11-25 21:19:15 +1100
commit138fee1cdec006be3857c5a3a32169a360bbc2ee (patch)
treedae1949d314800508e9a280e5c153fec06f078ef
parentc078f0f8ed2783f878148c69927a18c5b807ae59 (diff)
downloadlinux-138fee1cdec006be3857c5a3a32169a360bbc2ee.tar.gz
linux-138fee1cdec006be3857c5a3a32169a360bbc2ee.tar.xz
mm/gup: assert that the mmap lock is held in __get_user_pages()
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 <jannh@google.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Acked-by: Michel Lespinasse <walken@google.com> Cc: "Eric W . Biederman" <ebiederm@xmission.com> Cc: John Hubbard <jhubbard@nvidia.com> Cc: Mauro Carvalho Chehab <mchehab@kernel.org> Cc: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
-rw-r--r--mm/gup.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/mm/gup.c b/mm/gup.c
index c9b1b12fe72e..8cfe0d79c07b 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -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;