]> www.infradead.org Git - users/hch/block.git/commitdiff
mm/gup: assert that the mmap lock is held in __get_user_pages()
authorJann Horn <jannh@google.com>
Thu, 29 Oct 2020 01:10:05 +0000 (12:10 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 30 Oct 2020 03:23:50 +0000 (14:23 +1100)
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>
mm/gup.c

index 102877ed77a4b42af7e0a625cfc4b79791494f95..04e184068ccb512c1dc815984d514f757057ca29 100644 (file)
--- 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;