linux-stable/tools/include/uapi/linux
Daan De Meyer 859051dd16 bpf: Implement cgroup sockaddr hooks for unix sockets
These hooks allows intercepting connect(), getsockname(),
getpeername(), sendmsg() and recvmsg() for unix sockets. The unix
socket hooks get write access to the address length because the
address length is not fixed when dealing with unix sockets and
needs to be modified when a unix socket address is modified by
the hook. Because abstract socket unix addresses start with a
NUL byte, we cannot recalculate the socket address in kernelspace
after running the hook by calculating the length of the unix socket
path using strlen().

These hooks can be used when users want to multiplex syscall to a
single unix socket to multiple different processes behind the scenes
by redirecting the connect() and other syscalls to process specific
sockets.

We do not implement support for intercepting bind() because when
using bind() with unix sockets with a pathname address, this creates
an inode in the filesystem which must be cleaned up. If we rewrite
the address, the user might try to clean up the wrong file, leaking
the socket in the filesystem where it is never cleaned up. Until we
figure out a solution for this (and a use case for intercepting bind()),
we opt to not allow rewriting the sockaddr in bind() calls.

We also implement recvmsg() support for connected streams so that
after a connect() that is modified by a sockaddr hook, any corresponding
recmvsg() on the connected socket can also be modified to make the
connected program think it is connected to the "intended" remote.

Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Daan De Meyer <daan.j.demeyer@gmail.com>
Link: https://lore.kernel.org/r/20231011185113.140426-5-daan.j.demeyer@gmail.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
2023-10-11 17:27:47 -07:00
..
tc_act headers: Remove some left-over license text 2022-09-27 07:48:01 -07:00
bpf.h bpf: Implement cgroup sockaddr hooks for unix sockets 2023-10-11 17:27:47 -07:00
bpf_common.h
bpf_perf_event.h
btf.h bpf: Add btf enum64 support 2022-06-07 10:20:42 -07:00
const.h tools headers UAPI: Sync the linux/const.h with the kernel headers 2023-05-10 14:19:20 -03:00
erspan.h
ethtool.h
fadvise.h
fcntl.h tools headers uapi: Sync linux/fcntl.h with the kernel sources 2023-07-11 12:29:23 -03:00
filter.h
fs.h treewide: uapi: Replace zero-length arrays with flexible-array members 2022-06-28 21:26:05 +02:00
fscrypt.h tools headers UAPI: Sync linux/fscrypt.h with the kernel sources 2022-12-19 12:46:36 -03:00
hw_breakpoint.h Move bp_type_idx to include/linux/hw_breakpoint.h 2023-03-10 21:05:16 +01:00
if_link.h macvlan: Add netlink attribute for broadcast cutoff 2023-03-29 09:03:32 +01:00
if_tun.h treewide: uapi: Replace zero-length arrays with flexible-array members 2022-06-28 21:26:05 +02:00
if_xdp.h selftests/xsk: add basic multi-buffer test 2023-07-19 09:56:50 -07:00
in.h tools headers UAPI: Sync the linux/in.h with the kernel sources 2023-05-26 16:03:27 -03:00
kcmp.h
kvm.h tools headers UAPI: Sync linux/kvm.h with the kernel sources 2023-07-11 12:36:38 -03:00
mman.h tools headers UAPI: Sync files changed by new cachestat syscall with the kernel sources 2023-07-11 11:41:15 -03:00
mount.h tools include UAPI: Sync linux/mount.h copy with the kernel sources 2023-07-11 13:01:23 -03:00
netdev.h bpf: expose information about supported xdp metadata kfunc 2023-09-15 11:26:58 -07:00
netlink.h
openat2.h
perf_event.h tools include UAPI: Sync uapi/linux/perf_event.h with the kernel sources 2023-04-10 19:25:12 -03:00
pkt_cls.h treewide: uapi: Replace zero-length arrays with flexible-array members 2022-06-28 21:26:05 +02:00
pkt_sched.h
prctl.h tools headers UAPI: Sync linux/prctl.h with the kernel sources 2023-07-11 13:30:40 -03:00
sched.h
seg6.h treewide: uapi: Replace zero-length arrays with flexible-array members 2022-06-28 21:26:05 +02:00
seg6_local.h
stat.h tools headers uapi: Sync linux/stat.h with the kernel sources 2022-10-25 17:40:48 -03:00
stddef.h tools/headers: Pull in stddef.h to uapi to fix BPF selftests build in CI 2022-11-03 13:45:21 +01:00
tcp.h
tls.h
types.h
usbdevice_fs.h treewide: uapi: Replace zero-length arrays with flexible-array members 2022-06-28 21:26:05 +02:00
vhost.h tools include UAPI: Sync linux/vhost.h with the kernel sources 2023-07-14 10:16:03 -03:00