Skip to content

Commit f0e20b8

Browse files
isilenceaxboe
authored andcommitted
io_uring: fix lockup with timeouts
There is a recipe to deadlock the kernel: submit a timeout sqe with a linked_timeout (e.g. test_single_link_timeout_ception() from liburing), and SIGKILL the process. Then, io_kill_timeouts() takes @ctx->completion_lock, but the timeout isn't flagged with REQ_F_COMP_LOCKED, and will try to double grab it during io_put_free() to cancel the linked timeout. Probably, the same can happen with another io_kill_timeout() call site, that is io_commit_cqring(). Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent c1e2148 commit f0e20b8

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
@@ -1000,6 +1000,7 @@ static void io_kill_timeout(struct io_kiocb *req)
10001000
if (ret != -1) {
10011001
atomic_inc(&req->ctx->cq_timeouts);
10021002
list_del_init(&req->list);
1003+
req->flags |= REQ_F_COMP_LOCKED;
10031004
io_cqring_fill_event(req, 0);
10041005
io_put_req(req);
10051006
}

0 commit comments

Comments
 (0)