This is a note to let you know that I've just added the patch titled io_uring: fix tw losing poll events to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: io_uring-fix-tw-losing-poll-events.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Sat Dec 3 02:18:58 PM CET 2022 From: Pavel Begunkov <asml.silence@xxxxxxxxx> Date: Fri, 2 Dec 2022 14:27:12 +0000 Subject: io_uring: fix tw losing poll events To: stable@xxxxxxxxxxxxxxx Cc: Jens Axboe <axboe@xxxxxxxxx>, asml.silence@xxxxxxxxx Message-ID: <f802e6ca1e75aca0d42a4febe8088527d9b3bd93.1669990799.git.asml.silence@xxxxxxxxx> From: Pavel Begunkov <asml.silence@xxxxxxxxx> [ 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@xxxxxxxxxxxxxxx Fixes: aa43477b04025 ("io_uring: poll rework") Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx> Link: https://lore.kernel.org/r/00344d60f8b18907171178d7cf598de71d127b0b.1668710222.git.asml.silence@xxxxxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/io_uring.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -5440,6 +5440,13 @@ static int io_poll_check_events(struct i 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 }; Patches currently in stable-queue which might be from asml.silence@xxxxxxxxx are queue-5.15/io_uring-fix-tw-losing-poll-events.patch queue-5.15/io_uring-make-poll-refs-more-robust.patch queue-5.15/io_uring-cmpxchg-for-poll-arm-refs-release.patch queue-5.15/io_uring-poll-fix-poll_refs-race-with-cancelation.patch queue-5.15/io_uring-update-res-mask-in-io_poll_check_events.patch