]> git.itanic.dy.fi Git - linux-stable/commit
io_uring: use fget/fput consistently
authorJens Axboe <axboe@kernel.dk>
Tue, 28 Nov 2023 17:29:58 +0000 (10:29 -0700)
committerJens Axboe <axboe@kernel.dk>
Tue, 28 Nov 2023 18:56:29 +0000 (11:56 -0700)
commit73363c262d6a7d26063da96610f61baf69a70f7c
tree392b611882deb8cde1d43d8d81435d74ff20eb17
parent5cf4f52e6d8aa2d3b7728f568abbf9d42a3af252
io_uring: use fget/fput consistently

Normally within a syscall it's fine to use fdget/fdput for grabbing a
file from the file table, and it's fine within io_uring as well. We do
that via io_uring_enter(2), io_uring_register(2), and then also for
cancel which is invoked from the latter. io_uring cannot close its own
file descriptors as that is explicitly rejected, and for the cancel
side of things, the file itself is just used as a lookup cookie.

However, it is more prudent to ensure that full references are always
grabbed. For anything threaded, either explicitly in the application
itself or through use of the io-wq worker threads, this is what happens
anyway. Generalize it and use fget/fput throughout.

Also see the below link for more details.

Link: https://lore.kernel.org/io-uring/CAG48ez1htVSO3TqmrF8QcX2WFuYTRM-VZ_N10i-VZgbtg=NNqw@mail.gmail.com/
Suggested-by: Jann Horn <jannh@google.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/cancel.c
io_uring/io_uring.c