[UBUNTU OEM-5.17 2/5] io_uring: fix tw losing poll events
Thadeu Lima de Souza Cascardo
cascardo at canonical.com
Wed Apr 5 00:08:19 UTC 2023
From: Pavel Begunkov <asml.silence at gmail.com>
[ upstream commit 539bcb57da2f58886d7d5c17134236b0ec9cd15d ]
We may never try to process a poll wake and its mask if there was
multiple wake ups racing for queueing up a tw. Force
io_poll_check_events() to update the mask by vfs_poll().
Cc: stable at vger.kernel.org
Fixes: aa43477b04025 ("io_uring: poll rework")
Signed-off-by: Pavel Begunkov <asml.silence at gmail.com>
Link: https://lore.kernel.org/r/00344d60f8b18907171178d7cf598de71d127b0b.1668710222.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe at kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
(cherry picked from commit cd1981a8c30ddcab6e933c047c685ac649ac2ec9 linux-5.15.y)
CVE-2023-0468
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo at canonical.com>
---
fs/io_uring.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 6cb2d435decf..a460204a59f5 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5526,6 +5526,13 @@ static int io_poll_check_events(struct io_kiocb *req, bool locked)
return 0;
if (v & IO_POLL_CANCEL_FLAG)
return -ECANCELED;
+ /*
+ * cqe.res contains only events of the first wake up
+ * and all others are be lost. Redo vfs_poll() to get
+ * up to date state.
+ */
+ if ((v & IO_POLL_REF_MASK) != 1)
+ req->result = 0;
if (!req->result) {
struct poll_table_struct pt = { ._key = poll->events };
--
2.34.1
More information about the kernel-team
mailing list