diff options
author | 2024-07-24 22:22:14 -0500 | |
---|---|---|
committer | 2024-07-29 15:05:09 -0700 | |
commit | ba71ffb660e4d41fe589f2459fb888ea61fdb310 (patch) | |
tree | d575fcb4a546bb50bdab67ca6cd772b8bf648c0c | |
parent | selftests/bpf: Integrate test_xdp_veth into test_progs (diff) | |
download | wireguard-linux-ba71ffb660e4d41fe589f2459fb888ea61fdb310.tar.xz wireguard-linux-ba71ffb660e4d41fe589f2459fb888ea61fdb310.zip |
selftests/bpf: Load struct_ops map in global_maps_resize test
In prog_tests/test_global_maps_resize.c, we test various use cases for
resizing global maps. Commit 7244100e0389 ("libbpf: Don't take direct
pointers into BTF data from st_ops") updated libbpf to not store pointers
to volatile BTF data, which for some users, was causing a UAF when resizing
a datasec array.
Let's ensure we have coverage for resizing datasec arrays with struct_ops
progs by also including a struct_ops map and struct_ops prog in the
test_global_map_resize skeleton. The map is automatically loaded, so we
don't need to do anything other than add it to the BPF prog being tested
to get the coverage.
Signed-off-by: David Vernet <void@manifault.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240725032214.50676-1-void@manifault.com
Diffstat (limited to '')
-rw-r--r-- | tools/testing/selftests/bpf/progs/test_global_map_resize.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_global_map_resize.c b/tools/testing/selftests/bpf/progs/test_global_map_resize.c index 1fbb73d3e5d5..714b29c7f8b2 100644 --- a/tools/testing/selftests/bpf/progs/test_global_map_resize.c +++ b/tools/testing/selftests/bpf/progs/test_global_map_resize.c @@ -3,6 +3,7 @@ #include "vmlinux.h" #include <bpf/bpf_helpers.h> +#include <bpf/bpf_tracing.h> char _license[] SEC("license") = "GPL"; @@ -60,3 +61,18 @@ int data_array_sum(void *ctx) return 0; } + +SEC("struct_ops/test_1") +int BPF_PROG(test_1) +{ + return 0; +} + +struct bpf_testmod_ops { + int (*test_1)(void); +}; + +SEC(".struct_ops.link") +struct bpf_testmod_ops st_ops_resize = { + .test_1 = (void *)test_1 +}; |