mirror-linux/include/uapi/asm-generic
Kuniyuki Iwashima 77cbe1a6d8 af_unix: Introduce SO_PASSRIGHTS.
As long as recvmsg() or recvmmsg() is used with cmsg, it is not
possible to avoid receiving file descriptors via SCM_RIGHTS.

This behaviour has occasionally been flagged as problematic, as
it can be (ab)used to trigger DoS during close(), for example, by
passing a FUSE-controlled fd or a hung NFS fd.

For instance, as noted on the uAPI Group page [0], an untrusted peer
could send a file descriptor pointing to a hung NFS mount and then
close it.  Once the receiver calls recvmsg() with msg_control, the
descriptor is automatically installed, and then the responsibility
for the final close() now falls on the receiver, which may result
in blocking the process for a long time.

Regarding this, systemd calls cmsg_close_all() [1] after each
recvmsg() to close() unwanted file descriptors sent via SCM_RIGHTS.

However, this cannot work around the issue at all, because the final
fput() may still occur on the receiver's side once sendmsg() with
SCM_RIGHTS succeeds.  Also, even filtering by LSM at recvmsg() does
not work for the same reason.

Thus, we need a better way to refuse SCM_RIGHTS at sendmsg().

Let's introduce SO_PASSRIGHTS to disable SCM_RIGHTS.

Note that this option is enabled by default for backward
compatibility.

Link: https://uapi-group.org/kernel-features/#disabling-reception-of-scm_rights-for-af_unix-sockets #[0]
Link: https://github.com/systemd/systemd/blob/v257.5/src/basic/fd-util.c#L612-L628 #[1]
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2025-05-23 10:24:18 +01:00
..
Kbuild
auxvec.h
bitsperlong.h uapi: introduce uapi-friendly macros for GENMASK 2024-02-08 08:41:03 -05:00
bpf_perf_event.h
errno-base.h
errno.h
fcntl.h fs: get rid of __FMODE_NONOTIFY kludge 2024-12-09 11:34:29 +01:00
hugetlb_encode.h
int-l64.h
int-ll64.h
ioctl.h UAPI/ioctl: Improve parameter name of ioctl request definition helpers 2024-10-28 21:44:22 +00:00
ioctls.h
ipcbuf.h
kvm_para.h
mman-common.h mm/pkey: Add PKEY_UNRESTRICTED macro 2025-02-17 18:11:18 +00:00
mman.h mman: Add map_shadow_stack() flags 2024-10-04 12:04:33 +01:00
msgbuf.h
param.h
poll.h
posix_types.h
resource.h
sembuf.h
setup.h
shmbuf.h
siginfo.h posix-timers: Move sequence logic into struct k_itimer 2024-11-07 02:14:45 +01:00
signal-defs.h
signal.h
socket.h af_unix: Introduce SO_PASSRIGHTS. 2025-05-23 10:24:18 +01:00
sockios.h
stat.h
statfs.h
swab.h
termbits-common.h
termbits.h
termios.h
types.h
ucontext.h
unistd.h fs: add open_tree_attr() 2025-02-12 12:12:28 +01:00