The patch titled Subject: mm/gup: assert that the mmap lock is held in __get_user_pages() has been added to the -mm tree. Its filename is mm-gup-assert-that-the-mmap-lock-is-held-in-__get_user_pages.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-gup-assert-that-the-mmap-lock-is-held-in-__get_user_pages.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-gup-assert-that-the-mmap-lock-is-held-in-__get_user_pages.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Jann Horn <jannh@xxxxxxxxxx> Subject: 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@xxxxxxxxxxxxxx/ Link: https://lkml.kernel.org/r/CAG48ez1GM==OnHpS=ghqZNJPn02FCDUEHc7GQmGRMXUD_aKudg@xxxxxxxxxxxxxx Signed-off-by: Jann Horn <jannh@xxxxxxxxxx> Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx> Cc: "Eric W . Biederman" <ebiederm@xxxxxxxxxxxx> Cc: John Hubbard <jhubbard@xxxxxxxxxx> Cc: Mauro Carvalho Chehab <mchehab@xxxxxxxxxx> Cc: Michel Lespinasse <walken@xxxxxxxxxx> Cc: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/gup.c | 2 ++ 1 file changed, 2 insertions(+) --- a/mm/gup.c~mm-gup-assert-that-the-mmap-lock-is-held-in-__get_user_pages +++ a/mm/gup.c @@ -1027,6 +1027,8 @@ static long __get_user_pages(struct mm_s struct vm_area_struct *vma = NULL; struct follow_page_context ctx = { NULL }; + mmap_assert_locked(mm); + if (!nr_pages) return 0; _ Patches currently in -mm which might be from jannh@xxxxxxxxxx are mm-mmu_notifier-fix-mmget-assert-in-__mmu_interval_notifier_insert.patch binfmt_elf_fdpic-stop-using-dump_emit-on-user-pointers-on-mmu.patch coredump-let-dump_emit-bail-out-on-short-writes.patch coredump-refactor-page-range-dumping-into-common-helper.patch coredump-rework-elf-elf_fdpic-vma_dump_size-into-common-helper.patch binfmt_elf-binfmt_elf_fdpic-use-a-vma-list-snapshot.patch mm-gup-take-mmap_lock-in-get_dump_page.patch mm-remove-the-now-unnecessary-mmget_still_valid-hack.patch mm-gup_benchmark-take-the-mmap-lock-around-gup.patch binfmt_elf-take-the-mmap-lock-around-find_extend_vma.patch mmap-locking-api-dont-check-locking-if-the-mm-isnt-live-yet.patch mm-gup-assert-that-the-mmap-lock-is-held-in-__get_user_pages.patch