Skip to content

Commit 368c548

Browse files
isilenceaxboe
authored andcommitted
io_uring: don't set COMP_LOCKED if won't put
__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 <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 035fbaf commit 368c548

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/io_uring.c

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

17701770
ret = hrtimer_try_to_cancel(&io->timer);
17711771
if (ret != -1) {
1772+
req->flags |= REQ_F_COMP_LOCKED;
17721773
io_cqring_fill_event(req, -ECANCELED);
17731774
io_commit_cqring(ctx);
17741775
req->flags &= ~REQ_F_LINK_HEAD;
@@ -1791,7 +1792,6 @@ static bool __io_kill_linked_timeout(struct io_kiocb *req)
17911792
return false;
17921793

17931794
list_del_init(&link->link_list);
1794-
link->flags |= REQ_F_COMP_LOCKED;
17951795
wake_ev = io_link_cancel_timeout(link);
17961796
req->flags &= ~REQ_F_LINK_TIMEOUT;
17971797
return wake_ev;

0 commit comments

Comments
 (0)