]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
io_uring: fix REQ_F_COMP_LOCKED by killing it
authorPavel Begunkov <asml.silence@gmail.com>
Tue, 13 Oct 2020 08:44:00 +0000 (09:44 +0100)
committerJens Axboe <axboe@kernel.dk>
Sat, 17 Oct 2020 15:25:43 +0000 (09:25 -0600)
commit216578e55ac932cf5e348d9e65d8e129fc9e34cc
tree63a16a72d155a8c65c50480a4fe08c84c39fff79
parent4edf20f9990230e9b85e79954d5cd28fc93616e9
io_uring: fix REQ_F_COMP_LOCKED by killing it

REQ_F_COMP_LOCKED is used and implemented in a buggy way. The problem is
that the flag is set before io_put_req() but not cleared after, and if
that wasn't the final reference, the request will be freed with the flag
set from some other context, which may not hold a spinlock. That means
possible races with removing linked timeouts and unsynchronised
completion (e.g. access to CQ).

Instead of fixing REQ_F_COMP_LOCKED, kill the flag and use
task_work_add() to move such requests to a fresh context to free from
it, as was done with __io_free_req_finish().

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c