Skip to content

Commit 698d307

Browse files
axboedinguyen702
authored andcommitted
io_uring: remove poll entry from list when canceling all
[ upstream commmit 61bc84c ] When the ring is exiting, as part of the shutdown, poll requests are removed. But io_poll_remove_all() does not remove entries when finding them, and since completions are done out-of-band, we can find and remove the same entry multiple times. We do guard the poll execution by poll ownership, but that does not exclude us from reissuing a new one once the previous removal ownership goes away. This can race with poll execution as well, where we then end up seeing req->apoll be NULL because a previous task_work requeue finished the request. Remove the poll entry when we find it and get ownership of it. This prevents multiple invocations from finding it. Fixes: aa43477 ("io_uring: poll rework") Reported-by: Dylan Yudaken <[email protected]> Signed-off-by: Jens Axboe <[email protected]> [pavel: backport] Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5a31693 commit 698d307

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/io_uring.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5720,6 +5720,7 @@ static bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk,
57205720
list = &ctx->cancel_hash[i];
57215721
hlist_for_each_entry_safe(req, tmp, list, hash_node) {
57225722
if (io_match_task_safe(req, tsk, cancel_all)) {
5723+
hlist_del_init(&req->hash_node);
57235724
io_poll_cancel_req(req);
57245725
found = true;
57255726
}

0 commit comments

Comments
 (0)