Skip to content

Commit 9dfc978

Browse files
isilencejosephhz
authored andcommitted
io_uring: don't set COMP_LOCKED if won't put
ANBZ: torvalds#501 commit 368c548 upstream. __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]> Signed-off-by: Joseph Qi <[email protected]> Reviewed-by: Xiaoguang Wang <[email protected]>
1 parent bb0f3ad commit 9dfc978

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
@@ -1598,6 +1598,7 @@ static bool io_link_cancel_timeout(struct io_kiocb *req)
15981598

15991599
ret = hrtimer_try_to_cancel(&req->io->timeout.timer);
16001600
if (ret != -1) {
1601+
req->flags |= REQ_F_COMP_LOCKED;
16011602
io_cqring_fill_event(req, -ECANCELED);
16021603
io_commit_cqring(ctx);
16031604
req->flags &= ~REQ_F_LINK_HEAD;
@@ -1620,7 +1621,6 @@ static bool __io_kill_linked_timeout(struct io_kiocb *req)
16201621
return false;
16211622

16221623
list_del_init(&link->link_list);
1623-
link->flags |= REQ_F_COMP_LOCKED;
16241624
wake_ev = io_link_cancel_timeout(link);
16251625
req->flags &= ~REQ_F_LINK_TIMEOUT;
16261626
return wake_ev;

0 commit comments

Comments
 (0)