Skip to content

Commit ba71ffb

Browse files
Byte-Labanakryiko
authored andcommitted
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 7244100 ("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 <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 41b01a0 commit ba71ffb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tools/testing/selftests/bpf/progs/test_global_map_resize.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "vmlinux.h"
55
#include <bpf/bpf_helpers.h>
6+
#include <bpf/bpf_tracing.h>
67

78
char _license[] SEC("license") = "GPL";
89

@@ -60,3 +61,18 @@ int data_array_sum(void *ctx)
6061

6162
return 0;
6263
}
64+
65+
SEC("struct_ops/test_1")
66+
int BPF_PROG(test_1)
67+
{
68+
return 0;
69+
}
70+
71+
struct bpf_testmod_ops {
72+
int (*test_1)(void);
73+
};
74+
75+
SEC(".struct_ops.link")
76+
struct bpf_testmod_ops st_ops_resize = {
77+
.test_1 = (void *)test_1
78+
};

0 commit comments

Comments
 (0)