Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1699425

[PATCH] userfaultfd: non-cooperative: flush event_wqh at release time

From Mike Rapoport <rppt@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject [PATCH] userfaultfd: non-cooperative: flush event_wqh at release time
Date 2017-07-30 09:10 +0200
Message-ID <u8Qwq-5B9-11@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


There maybe still threads waiting on event_wqh at the time the userfault
file descriptor is closed. Flush the events wait-queue to prevent waiting
threads from hanging.

Cc: stable@vger.kernel.org
Fixes: 9cd75c3cd4c3d ("userfaultfd: non-cooperative: add ability to report
non-PF events from uffd descriptor")

Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
---
 fs/userfaultfd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 2d8c2d848668..06ea26b8c996 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -854,6 +854,9 @@ static int userfaultfd_release(struct inode *inode, struct file *file)
 	__wake_up_locked_key(&ctx->fault_wqh, TASK_NORMAL, &range);
 	spin_unlock(&ctx->fault_pending_wqh.lock);
 
+	/* Flush pending events that may still wait on event_wqh */
+	wake_up_all(&ctx->event_wqh);
+
 	wake_up_poll(&ctx->fd_wqh, POLLHUP);
 	userfaultfd_ctx_put(ctx);
 	return 0;
-- 
2.7.4

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] userfaultfd: non-cooperative: flush event_wqh at release time Mike Rapoport <rppt@linux.vnet.ibm.com> - 2017-07-30 09:10 +0200

csiph-web