aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJann Horn <jannh@google.com>2020-12-10 15:42:20 +1100
committerStephen Rothwell <sfr@canb.auug.org.au>2020-12-16 18:03:05 +1100
commite0cb591b165c110c6b3baf38838fe4c2255f1822 (patch)
treef257ab94fa55a737077d91f82ea066267f4c74d4
parenta263cb22cd048905823a8ddc1ff96a0069a94daa (diff)
downloadlinux-e0cb591b165c110c6b3baf38838fe4c2255f1822.tar.gz
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 e4c224cd9661..8a26e0b5eb80 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -996,6 +996,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;