diff options
author | Andrea Arcangeli <aarcange@redhat.com> | 2017-03-09 19:16:52 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-03-09 20:01:09 -0500 |
commit | 9a69a829f9b656c2a220d65a94ecf7b5887c5da1 (patch) | |
tree | dee2ed7716c4d6ce06f1e6762c6eb5f002b91f23 | |
parent | dd0db88d8094a6d9d4d1fc5fcd56ab619f54ccf8 (diff) |
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>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/userfaultfd.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 16d0cc600fa9..668bbbd2e04d 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c | |||
@@ -530,8 +530,13 @@ out: | |||
530 | static int userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx, | 530 | static int userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx, |
531 | struct userfaultfd_wait_queue *ewq) | 531 | struct userfaultfd_wait_queue *ewq) |
532 | { | 532 | { |
533 | int ret = 0; | 533 | int ret; |
534 | |||
535 | ret = -1; | ||
536 | if (WARN_ON_ONCE(current->flags & PF_EXITING)) | ||
537 | goto out; | ||
534 | 538 | ||
539 | ret = 0; | ||
535 | ewq->ctx = ctx; | 540 | ewq->ctx = ctx; |
536 | init_waitqueue_entry(&ewq->wq, current); | 541 | init_waitqueue_entry(&ewq->wq, current); |
537 | 542 | ||
@@ -566,7 +571,7 @@ static int userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx, | |||
566 | * ctx may go away after this if the userfault pseudo fd is | 571 | * ctx may go away after this if the userfault pseudo fd is |
567 | * already released. | 572 | * already released. |
568 | */ | 573 | */ |
569 | 574 | out: | |
570 | userfaultfd_ctx_put(ctx); | 575 | userfaultfd_ctx_put(ctx); |
571 | return ret; | 576 | return ret; |
572 | } | 577 | } |