]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
selftests/bpf: Add kernel socket operation tests
authorJordan Rife <jrife@google.com>
Mon, 29 Apr 2024 21:45:23 +0000 (16:45 -0500)
committerMartin KaFai Lau <martin.lau@kernel.org>
Thu, 2 May 2024 22:23:31 +0000 (15:23 -0700)
commite0c8a7e7526ff1526d4dcc7d71aad4e7fe2ec767
tree68733e5147e407466dbcdd8d6248ce797315cb8a
parent524e05ac4e14bb50b4f442e1fe88540abc9b72fd
selftests/bpf: Add kernel socket operation tests

This patch creates two sets of sock_ops that call out to the SYSCALL
hooks in the sock_addr_kern BPF program and uses them to construct
test cases for the range of supported operations (kernel_connect(),
kernel_bind(), kernel_sendms(), sock_sendmsg(), kernel_getsockname(),
kenel_getpeername()). This ensures that these interact with BPF sockaddr
hooks as intended.

Beyond this it also ensures that these operations do not modify their
address parameter, providing regression coverage for the issues
addressed by this set of patches:

- commit 0bdf399342c5("net: Avoid address overwrite in kernel_connect")
- commit 86a7e0b69bd5("net: prevent rewrite of msg_name in sock_sendmsg()")
- commit c889a99a21bf("net: prevent address rewrite in kernel_bind()")
- commit 01b2885d9415("net: Save and restore msg_namelen in sock_sendmsg")

Signed-off-by: Jordan Rife <jrife@google.com>
Link: https://lore.kernel.org/r/20240429214529.2644801-7-jrife@google.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
tools/testing/selftests/bpf/prog_tests/sock_addr.c