mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* + mm-gup-fix-fixup_user_fault-on-multiple-retries.patch added to -mm tree
@ 2020-05-05 20:27 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2020-05-05 20:27 UTC (permalink / raw)
  To: alex.williamson, bgeffon, mm-commits, peterx


The patch titled
     Subject: mm/gup: fix fixup_user_fault() on multiple retries
has been added to the -mm tree.  Its filename is
     mm-gup-fix-fixup_user_fault-on-multiple-retries.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/mm-gup-fix-fixup_user_fault-on-multiple-retries.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/mm-gup-fix-fixup_user_fault-on-multiple-retries.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@redhat.com>
Subject: mm/gup: fix fixup_user_fault() on multiple retries

This part is overlooked when reworking the gup code on multiple retries. 
When we get the 2nd+ retry, we'll be with TRIED flag set.  Current code
will bail out on the 2nd retry because the !TRIED check will fail so the
retry logic will be skipped.  What's worse is that, it will also return
zero which errornously hints the caller that the page is faulted in while
it's not.

The !TRIED flag check seems to not be needed even before the mutliple
retries change because if we get a VM_FAULT_RETRY, it must be the 1st
retry, and we should not have TRIED set for that.

Fix it by removing the !TRIED check, at the meantime check against fatal
signals properly before the page fault so we can still properly respond to
the user killing the process during retries.

Link: http://lkml.kernel.org/r/20200502003523.8204-1-peterx@redhat.com
Fixes: 4426e945df58 ("mm/gup: allow VM_FAULT_RETRY for multiple times")
Signed-off-by: Peter Xu <peterx@redhat.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Brian Geffon <bgeffon@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/gup.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

--- a/mm/gup.c~mm-gup-fix-fixup_user_fault-on-multiple-retries
+++ a/mm/gup.c
@@ -1218,6 +1218,10 @@ retry:
 	if (!vma_permits_fault(vma, fault_flags))
 		return -EFAULT;
 
+	if ((fault_flags & FAULT_FLAG_KILLABLE) &&
+	    fatal_signal_pending(current))
+		return -EINTR;
+
 	ret = handle_mm_fault(vma, address, fault_flags);
 	major |= ret & VM_FAULT_MAJOR;
 	if (ret & VM_FAULT_ERROR) {
@@ -1230,11 +1234,9 @@ retry:
 
 	if (ret & VM_FAULT_RETRY) {
 		down_read(&mm->mmap_sem);
-		if (!(fault_flags & FAULT_FLAG_TRIED)) {
-			*unlocked = true;
-			fault_flags |= FAULT_FLAG_TRIED;
-			goto retry;
-		}
+		*unlocked = true;
+		fault_flags |= FAULT_FLAG_TRIED;
+		goto retry;
 	}
 
 	if (tsk) {
_

Patches currently in -mm which might be from peterx@redhat.com are

mm-gup-fix-fixup_user_fault-on-multiple-retries.patch

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-05 20:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 20:27 + mm-gup-fix-fixup_user_fault-on-multiple-retries.patch added to -mm tree akpm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).