Re: [PATCH RFC POC 22/50] net: install SCM_RIGHTS descriptors when recvmsg() returns
From: sashiko-bot
Date: Tue Sep 15 2026 - 08:27:53 EST
> 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) <brauner@xxxxxxxxxx>
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-4d5217d6b246@xxxxxxxxxx?part=22