Skip to content

Commit

Permalink
io_uring/poll: don't reissue in case of poll race on multishot request
Browse files Browse the repository at this point in the history
A previous commit fixed a poll race that can occur, but it's only
applicable for multishot requests. For a multishot request, we can safely
ignore a spurious wakeup, as we never leave the waitqueue to begin with.

A blunt reissue of a multishot armed request can cause us to leak a
buffer, if they are ring provided. While this seems like a bug in itself,
it's not really defined behavior to reissue a multishot request directly.
It's less efficient to do so as well, and not required to rearm anything
like it is for singleshot poll requests.

Cc: [email protected]
Fixes: 6e5aedb ("io_uring/poll: attempt request issue after racy poll wakeup")
Reported-and-tested-by: Olivier Langlois <[email protected]>
Link: axboe/liburing#778
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Jan 20, 2023
1 parent 8579538 commit 8caa03f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion io_uring/poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,12 @@ static int io_poll_check_events(struct io_kiocb *req, bool *locked)
* to the waitqueue, so if we get nothing back, we
* should be safe and attempt a reissue.
*/
if (unlikely(!req->cqe.res))
if (unlikely(!req->cqe.res)) {
/* Multishot armed need not reissue */
if (!(req->apoll_events & EPOLLONESHOT))
continue;
return IOU_POLL_REISSUE;
}
}
if (req->apoll_events & EPOLLONESHOT)
return IOU_POLL_DONE;
Expand Down

0 comments on commit 8caa03f

Please sign in to comment.