Skip to content

Commit ccbf726

Browse files
committed
io_uring: perform poll removal even if async work removal is successful
An active work can have poll armed, hence it's not enough to just do the async work removal and return the value if it's different from "not found". Rather than make poll removal special, just fall through to do the remaining type lookups and removals. Reported-by: Florian Fischer <florian.fl.fischer@fau.de> Link: https://lore.kernel.org/io-uring/20220118151337.fac6cthvbnu7icoc@pasture/ Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 361aee4 commit ccbf726

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

fs/io_uring.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6386,16 +6386,21 @@ static int io_try_cancel_userdata(struct io_kiocb *req, u64 sqe_addr)
63866386
WARN_ON_ONCE(!io_wq_current_is_worker() && req->task != current);
63876387

63886388
ret = io_async_cancel_one(req->task->io_uring, sqe_addr, ctx);
6389-
if (ret != -ENOENT)
6390-
return ret;
6389+
/*
6390+
* Fall-through even for -EALREADY, as we may have poll armed
6391+
* that need unarming.
6392+
*/
6393+
if (!ret)
6394+
return 0;
63916395

63926396
spin_lock(&ctx->completion_lock);
6397+
ret = io_poll_cancel(ctx, sqe_addr, false);
6398+
if (ret != -ENOENT)
6399+
goto out;
6400+
63936401
spin_lock_irq(&ctx->timeout_lock);
63946402
ret = io_timeout_cancel(ctx, sqe_addr);
63956403
spin_unlock_irq(&ctx->timeout_lock);
6396-
if (ret != -ENOENT)
6397-
goto out;
6398-
ret = io_poll_cancel(ctx, sqe_addr, false);
63996404
out:
64006405
spin_unlock(&ctx->completion_lock);
64016406
return ret;

0 commit comments

Comments
 (0)