io_uring: fix tw losing poll events

[ upstream commit 539bcb57da ]

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@vger.kernel.org
Fixes: aa43477b04 ("io_uring: poll rework")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/00344d60f8b18907171178d7cf598de71d127b0b.1668710222.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Pavel Begunkov 2022-12-02 14:27:12 +00:00 коммит произвёл Greg Kroah-Hartman
Родитель 62321dc7b0
Коммит cd1981a8c3
1 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -5440,6 +5440,13 @@ static int io_poll_check_events(struct io_kiocb *req)
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 };