bpf: Propagate modified uaddrlen from cgroup sockaddr programs
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 11 Oct 2023 18:51:04 +0000 (20:51 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Feb 2024 00:19:04 +0000 (16:19 -0800)
commit6d71331eb044c28958b89e662ea0e11a0cd57de5
tree5d6801503c70e6efdba0db7352b299585c1ef9c6
parentb6e1a1b3b27030b5cf86ba69a47a257b16760867
bpf: Propagate modified uaddrlen from cgroup sockaddr programs

[ Upstream commit fefba7d1ae198dcbf8b3b432de46a4e29f8dbd8c ]

As prep for adding unix socket support to the cgroup sockaddr hooks,
let's propagate the sockaddr length back to the caller after running
a bpf cgroup sockaddr hook program. While not important for AF_INET or
AF_INET6, the sockaddr length is important when working with AF_UNIX
sockaddrs as the size of the sockaddr cannot be determined just from the
address family or the sockaddr's contents.

__cgroup_bpf_run_filter_sock_addr() is modified to take the uaddrlen as
an input/output argument. After running the program, the modified sockaddr
length is stored in the uaddrlen pointer.

Signed-off-by: Daan De Meyer <daan.j.demeyer@gmail.com>
Link: https://lore.kernel.org/r/20231011185113.140426-3-daan.j.demeyer@gmail.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Stable-dep-of: c5114710c8ce ("xsk: fix usage of multi-buffer BPF helpers for ZC XDP")
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/bpf-cgroup.h
include/linux/filter.h
kernel/bpf/cgroup.c
net/ipv4/af_inet.c
net/ipv4/ping.c
net/ipv4/tcp_ipv4.c
net/ipv4/udp.c
net/ipv6/af_inet6.c
net/ipv6/ping.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c