• Pavel Begunkov's avatar
    io_uring: fix REQ_F_COMP_LOCKED by killing it · 216578e5
    Pavel Begunkov authored
    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: default avatarPavel Begunkov <asml.silence@gmail.com>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    216578e5
io_uring.c 229 KB