The patch titled Subject: mm/gup: mark lock taken only after a successful retake has been added to the -mm tree. Its filename is mm-gup-mark-lock-taken-only-after-a-successful-retake.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-gup-mark-lock-taken-only-after-a-successful-retake.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-gup-mark-lock-taken-only-after-a-successful-retake.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: Peter Xu <peterx@xxxxxxxxxx> Subject: mm/gup: mark lock taken only after a successful retake It's definitely incorrect to mark the lock as taken even if down_read_killable() failed. It's overlooked when we switched from down_read() to down_read_killable() because down_read() won't fail while down_read_killable() could. Link: http://lkml.kernel.org/r/20200407204754.GA66033@xz-x1 Fixes: 71335f37c5e8 ("mm/gup: allow to react to fatal signals") Signed-off-by: Peter Xu <peterx@xxxxxxxxxx> Reported-by: syzbot+a8c70b7f3579fc0587dc@xxxxxxxxxxxxxxxxxxxxxxxxx Tested-by: syzbot+a8c70b7f3579fc0587dc@xxxxxxxxxxxxxxxxxxxxxxxxx Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/gup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/gup.c~mm-gup-mark-lock-taken-only-after-a-successful-retake +++ a/mm/gup.c @@ -1329,7 +1329,6 @@ retry: if (fatal_signal_pending(current)) break; - *locked = 1; ret = down_read_killable(&mm->mmap_sem); if (ret) { BUG_ON(ret > 0); @@ -1338,6 +1337,7 @@ retry: break; } + *locked = 1; ret = __get_user_pages(tsk, mm, start, 1, flags | FOLL_TRIED, pages, NULL, locked); if (!*locked) { _ Patches currently in -mm which might be from peterx@xxxxxxxxxx are mm-merge-parameters-for-change_protection.patch userfaultfd-wp-apply-_page_uffd_wp-bit.patch userfaultfd-wp-drop-_page_uffd_wp-properly-when-fork.patch userfaultfd-wp-add-pmd_swp_uffd_wp-helpers.patch userfaultfd-wp-support-swap-and-page-migration.patch khugepaged-skip-collapse-if-uffd-wp-detected.patch userfaultfd-wp-dont-wake-up-when-doing-write-protect.patch userfaultfd-wp-declare-_uffdio_writeprotect-conditionally.patch userfaultfd-selftests-refactor-statistics.patch userfaultfd-selftests-add-write-protect-test.patch mm-mempolicy-allow-lookup_node-to-handle-fatal-signal.patch mm-gup-mark-lock-taken-only-after-a-successful-retake.patch