Skip to content

Commit 2178d10

Browse files
isilencegregkh
authored andcommitted
io_uring: don't set COMP_LOCKED if won't put
[ Upstream commit 368c548 ] __io_kill_linked_timeout() sets REQ_F_COMP_LOCKED for a linked timeout even if it can't cancel it, e.g. it's already running. It not only races with io_link_timeout_fn() for ->flags field, but also leaves the flag set and so io_link_timeout_fn() may find it and decide that it holds the lock. Hopefully, the second problem is potential. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f8462e2 commit 2178d10

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/io_uring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1650,6 +1650,7 @@ static bool io_link_cancel_timeout(struct io_kiocb *req)
16501650

16511651
ret = hrtimer_try_to_cancel(&req->io->timeout.timer);
16521652
if (ret != -1) {
1653+
req->flags |= REQ_F_COMP_LOCKED;
16531654
io_cqring_fill_event(req, -ECANCELED);
16541655
io_commit_cqring(ctx);
16551656
req->flags &= ~REQ_F_LINK_HEAD;
@@ -1672,7 +1673,6 @@ static bool __io_kill_linked_timeout(struct io_kiocb *req)
16721673
return false;
16731674

16741675
list_del_init(&link->link_list);
1675-
link->flags |= REQ_F_COMP_LOCKED;
16761676
wake_ev = io_link_cancel_timeout(link);
16771677
req->flags &= ~REQ_F_LINK_TIMEOUT;
16781678
return wake_ev;

0 commit comments

Comments
 (0)