From: Andrea Arcangeli <aarcange@redhat.com>
To: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>
Cc: Michael Rapoport <RAPOPORT@il.ibm.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Mike Kravetz <mike.kravetz@oracle.com>,
Pavel Emelyanov <xemul@parallels.com>,
Hillf Danton <hillf.zj@alibaba-inc.com>
Subject: [PATCH 2/3] userfaultfd: non-cooperative: robustness check
Date: Fri, 24 Feb 2017 19:19:56 +0100 [thread overview]
Message-ID: <20170224181957.19736-3-aarcange@redhat.com> (raw)
In-Reply-To: <20170224181957.19736-1-aarcange@redhat.com>
Similar to the handle_userfault() case, also make sure to never
attempt to send any event past the PF_EXITING point of no return.
This is purely a robustness check.
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
---
fs/userfaultfd.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 52733a7..3d7c248 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -529,8 +529,13 @@ int handle_userfault(struct vm_fault *vmf, unsigned long reason)
static int userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx,
struct userfaultfd_wait_queue *ewq)
{
- int ret = 0;
+ int ret;
+
+ ret = -1;
+ if (WARN_ON_ONCE(current->flags & PF_EXITING))
+ goto out;
+ ret = 0;
ewq->ctx = ctx;
init_waitqueue_entry(&ewq->wq, current);
@@ -565,7 +570,7 @@ static int userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx,
* ctx may go away after this if the userfault pseudo fd is
* already released.
*/
-
+out:
userfaultfd_ctx_put(ctx);
return ret;
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2017-02-24 18:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-24 18:19 [PATCH 0/3] userfaultfd non-cooperative further update for 4.11 merge window Andrea Arcangeli
2017-02-24 18:19 ` [PATCH 1/3] userfaultfd: non-cooperative: rollback userfaultfd_exit Andrea Arcangeli
2017-02-24 18:19 ` Andrea Arcangeli [this message]
2017-02-24 18:19 ` [PATCH 3/3] userfaultfd: non-cooperative: release all ctx in dup_userfaultfd_complete Andrea Arcangeli
2017-02-28 7:15 ` [PATCH 0/3] userfaultfd non-cooperative further update for 4.11 merge window Mike Rapoport
2017-03-01 5:17 ` [PATCH 1.5/3] userfaultfd: documentation fixup after removal of UFFD_EVENT_EXIT Mike Rapoport
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170224181957.19736-3-aarcange@redhat.com \
--to=aarcange@redhat.com \
--cc=RAPOPORT@il.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=dgilbert@redhat.com \
--cc=hillf.zj@alibaba-inc.com \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=xemul@parallels.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).