* [PATCH bpf-next] selftests/bpf: Load struct_ops map in global_maps_resize test
@ 2024-07-25 3:22 David Vernet
2024-07-25 20:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: David Vernet @ 2024-07-25 3:22 UTC (permalink / raw)
To: bpf
Cc: ast, daniel, andrii, martin.lau, song, yonghong.song,
john.fastabend, kpsingh, sdf, haoluo, jolsa, linux-kernel,
kernel-team
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>
---
.../selftests/bpf/progs/test_global_map_resize.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
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
+};
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH bpf-next] selftests/bpf: Load struct_ops map in global_maps_resize test
2024-07-25 3:22 [PATCH bpf-next] selftests/bpf: Load struct_ops map in global_maps_resize test David Vernet
@ 2024-07-25 20:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-07-25 20:40 UTC (permalink / raw)
To: David Vernet
Cc: bpf, ast, daniel, andrii, martin.lau, song, yonghong.song,
john.fastabend, kpsingh, sdf, haoluo, jolsa, linux-kernel,
kernel-team
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Wed, 24 Jul 2024 22:22:14 -0500 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [bpf-next] selftests/bpf: Load struct_ops map in global_maps_resize test
https://git.kernel.org/bpf/bpf-next/c/7d30b8aa4fc3
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-25 20:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-25 3:22 [PATCH bpf-next] selftests/bpf: Load struct_ops map in global_maps_resize test David Vernet
2024-07-25 20:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox