• Pavel Begunkov's avatar
    io_uring: fix files grab/cancel race · af604703
    Pavel Begunkov authored
    When one task is in io_uring_cancel_files() and another is doing
    io_prep_async_work() a race may happen. That's because after accounting
    a request inflight in first call to io_grab_identity() it still may fail
    and go to io_identity_cow(), which migh briefly keep dangling
    work.identity and not only.
    
    Grab files last, so io_prep_async_work() won't fail if it did get into
    ->inflight_list.
    
    note: the bug shouldn't exist after making io_uring_cancel_files() not
    poking into other tasks' requests.
    Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    af604703
io_uring.c 236 KB