* [patch 09/26] userfaultfd: non-cooperative: robustness check
@ 2017-03-10 0:16 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2017-03-10 0:16 UTC (permalink / raw)
To: torvalds, mm-commits, akpm, aarcange, dgilbert, hillf.zj,
mike.kravetz, rppt, xemul
From: Andrea Arcangeli <aarcange@redhat.com>
Subject: userfaultfd: non-cooperative: robustness check
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.
Link: http://lkml.kernel.org/r/20170224181957.19736-3-aarcange@redhat.com
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Acked-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Pavel Emelyanov <xemul@parallels.com>
Cc: Hillf Danton <hillf.zj@alibaba-inc.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
fs/userfaultfd.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff -puN fs/userfaultfd.c~userfaultfd-non-cooperative-robustness-check fs/userfaultfd.c
--- a/fs/userfaultfd.c~userfaultfd-non-cooperative-robustness-check
+++ a/fs/userfaultfd.c
@@ -530,8 +530,13 @@ out:
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);
@@ -566,7 +571,7 @@ static int userfaultfd_event_wait_comple
* ctx may go away after this if the userfault pseudo fd is
* already released.
*/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-03-10 0:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-10 0:16 [patch 09/26] userfaultfd: non-cooperative: robustness check 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).