Commit 9a69a829 authored by Andrea Arcangeli's avatar Andrea Arcangeli Committed by Linus Torvalds

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.comSigned-off-by: default avatarAndrea Arcangeli <aarcange@redhat.com>
Acked-by: default avatarMike 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent dd0db88d
...@@ -530,8 +530,13 @@ int handle_userfault(struct vm_fault *vmf, unsigned long reason) ...@@ -530,8 +530,13 @@ int handle_userfault(struct vm_fault *vmf, unsigned long reason)
static int userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx, static int userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx,
struct userfaultfd_wait_queue *ewq) 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; ewq->ctx = ctx;
init_waitqueue_entry(&ewq->wq, current); init_waitqueue_entry(&ewq->wq, current);
...@@ -566,7 +571,7 @@ static int userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx, ...@@ -566,7 +571,7 @@ static int userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx,
* ctx may go away after this if the userfault pseudo fd is * ctx may go away after this if the userfault pseudo fd is
* already released. * already released.
*/ */
out:
userfaultfd_ctx_put(ctx); userfaultfd_ctx_put(ctx);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment