[RHEL8,COMMIT] userfaultfd: don't retake mmap_sem to emulate NOPAGE

Submitted by Konstantin Khorenko on April 20, 2020, 7:34 a.m.


Message ID 202004200734.03K7YHpg015914@finist_co8.work.ct
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko April 20, 2020, 7:34 a.m.
The commit is pushed to "branch-rh8-4.18.0-80.1.2.vz8.3.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-80.1.2.vz8.3.6
commit a92855fca64d4f03c797dc84e8964e4867467844
Author: Peter Xu <peterx@redhat.com>
Date:   Mon Apr 20 10:34:17 2020 +0300

    userfaultfd: don't retake mmap_sem to emulate NOPAGE
    This patch removes the risk path in handle_userfault() then we will be
    sure that the callers of handle_mm_fault() will know that the VMAs might
    have changed.  Meanwhile with previous patch we don't lose responsiveness
    as well since the core mm code now can handle the nonfatal userspace
    signals even if we return VM_FAULT_RETRY.
    Suggested-by: Andrea Arcangeli <aarcange@redhat.com>
    Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Peter Xu <peterx@redhat.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Tested-by: Brian Geffon <bgeffon@google.com>
    Reviewed-by: Jerome Glisse <jglisse@redhat.com>
    Cc: Bobby Powers <bobbypowers@gmail.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Denis Plotnikov <dplotnikov@virtuozzo.com>
    Cc: "Dr . David Alan Gilbert" <dgilbert@redhat.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: "Kirill A . Shutemov" <kirill@shutemov.name>
    Cc: Martin Cracauer <cracauer@cons.org>
    Cc: Marty McFadden <mcfadden8@llnl.gov>
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: Maya Gokhale <gokhale2@llnl.gov>
    Cc: Mel Gorman <mgorman@suse.de>
    Cc: Mike Kravetz <mike.kravetz@oracle.com>
    Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
    Cc: Pavel Emelyanov <xemul@openvz.org>
    Link: http://lkml.kernel.org/r/20200220160234.9646-1-peterx@redhat.com
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    (cherry picked from commit ef429ee7409aa7cbe4c3c9e2df5dc6abedfab493)
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
 fs/userfaultfd.c | 24 ------------------------
 1 file changed, 24 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 2dcade9daa73..905bad9139bb 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -517,30 +517,6 @@  int handle_userfault(struct vm_fault *vmf, unsigned long reason)
-	if (return_to_userland) {
-		if (signal_pending(current) &&
-		    !fatal_signal_pending(current)) {
-			/*
-			 * If we got a SIGSTOP or SIGCONT and this is
-			 * a normal userland page fault, just let
-			 * userland return so the signal will be
-			 * handled and gdb debugging works.  The page
-			 * fault code immediately after we return from
-			 * this function is going to release the
-			 * mmap_sem and it's not depending on it
-			 * (unlike gup would if we were not to return
-			 *
-			 * If a fatal signal is pending we still take
-			 * the streamlined VM_FAULT_RETRY failure path
-			 * and there's no need to retake the mmap_sem
-			 * in such case.
-			 */
-			down_read(&mm->mmap_sem);
-			ret = VM_FAULT_NOPAGE;
-		}
-	}
 	 * Here we race with the list_del; list_add in
 	 * userfaultfd_ctx_read(), however because we don't ever run