linux-stable/io_uring
Jens Axboe 0c7df8c241 io_uring: use fget/fput consistently
[ Upstream commit 73363c262d ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-20 11:51:38 +01:00
..
advise.c
advise.h
alloc_cache.h
cancel.c io_uring: use fget/fput consistently 2024-01-20 11:51:38 +01:00
cancel.h
epoll.c
epoll.h
fdinfo.c io_uring/fdinfo: remove need for sqpoll lock for thread/pid retrieval 2023-11-28 17:19:52 +00:00
fdinfo.h
filetable.c
filetable.h
fs.c io_uring/fs: consider link->flags when getting path for LINKAT 2023-12-03 07:33:07 +01:00
fs.h
io-wq.c
io-wq.h
io_uring.c io_uring: use fget/fput consistently 2024-01-20 11:51:38 +01:00
io_uring.h io_uring: enable io_mem_alloc/free to be used in other parts 2023-12-08 08:52:20 +01:00
kbuf.c io_uring/kbuf: check for buffer list readiness after NULL check 2023-12-13 18:45:17 +01:00
kbuf.h io_uring/kbuf: defer release of mapped buffer rings 2023-12-08 08:52:20 +01:00
Makefile
msg_ring.c
msg_ring.h
net.c io_uring/net: ensure socket is marked connected on connect retry 2023-11-20 11:59:38 +01:00
net.h
nop.c
nop.h
notif.c
notif.h
opdef.c
opdef.h
openclose.c
openclose.h
poll.c
poll.h
refs.h
rsrc.c io_uring: fix off-by one bvec index 2023-12-03 07:33:07 +01:00
rsrc.h io_uring/af_unix: disable sending io_uring over sockets 2023-12-13 18:45:20 +01:00
rw.c
rw.h
slist.h
splice.c
splice.h
sqpoll.c io_uring/fdinfo: remove need for sqpoll lock for thread/pid retrieval 2023-11-28 17:19:52 +00:00
sqpoll.h
statx.c
statx.h
sync.c
sync.h
tctx.c
tctx.h
timeout.c
timeout.h
uring_cmd.c io_uring/cmd: fix breakage in SOCKET_URING_OP_SIOC* implementation 2023-12-20 17:01:52 +01:00
uring_cmd.h
xattr.c
xattr.h