> scm_recv_one_fd() allocates a descriptor, writes the number into the > control message and installs the file right there, one descriptor at a > time. Everything that recvmsg() does after scm_detach_fds() can still > fail though. When it does the syscall returns -EFAULT while the received > descriptors are already in the table and the caller has no way to tell. > > Reserve the descriptor with fd_prepare() and stage the file with > fd_stage(). The number is written to userspace as before, but the file > is only installed when recvmsg() returns success and dropped together > with the descriptor when it returns an error. > > A control message that doesn't fit still gets only the descriptors it > can report and MSG_CTRUNC. > > IORING_OP_RECVMSG reaches the same code from io-wq workers and the > SQPOLL thread. io_uring requests commit their reservations before the > completion is posted. > > Signed-off-by: Christian Brauner (Amutable) <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great! -- Sashiko AI review ยท https://sashiko.dev/#/patchset/20260915-work-fd-reserve-unify-folded-v1-0-4d5217d6b...@kernel.org?part=22
