selftests/bpf: Negative test case for tail call map
Subsystems (3)
PATCH v4 1/1 selftests/bpf: Negative test case for tail call map
This patch adds a negative test case for the following verifier error.
expected prog array map for tail call
---
Changes in v4:
- Sent an earlier version as v3 by mistake. Monday is hard...
Changes in v3:
- Removed BPF_F_ANY_ALIGNMENT flag as suggested by Yonghong.
Changes in v2:
- Moved the test to prog_tests format as suggested by Eduard.
- Rebased.
- v1: https://lore.kernel.org/bpf/7cec754c8d4cc2d93a50e9091d7ccc7f33d454d4.1751578055.git.paul.chaignon@gmail.com/
.../selftests/bpf/prog_tests/verifier.c | 2 ++ .../selftests/bpf/progs/verifier_tailcall.c | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tools/testing/selftests/bpf/progs/verifier_tailcall.c
tools/testing/selftests/bpf/prog_tests/verifier.c +2 -0
@@ -85,6 +85,7 @@#include "verifier_store_release.skel.h" #include "verifier_subprog_precision.skel.h" #include "verifier_subreg.skel.h" +#include "verifier_tailcall.skel.h" #include "verifier_tailcall_jit.skel.h" #include "verifier_typedef.skel.h" #include "verifier_uninit.skel.h"
@@ -219,6 +220,7 @@ void test_verifier_stack_ptr(void) { RUN(verifier_stack_ptr); }void test_verifier_store_release (void ) {RUN (verifier_store_release); }void test_verifier_subprog_precision (void ) {RUN (verifier_subprog_precision); }void test_verifier_subreg (void ) {RUN (verifier_subreg); } +void test_verifier_tailcall (void ) {RUN (verifier_tailcall); }void test_verifier_tailcall_jit (void ) {RUN (verifier_tailcall_jit); }void test_verifier_typedef (void ) {RUN (verifier_typedef); }void test_verifier_uninit (void ) {RUN (verifier_uninit); }
tools/testing/selftests/bpf/progs/verifier_tailcall.c new file +31 -0
@@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/bpf.h> +#include <bpf/bpf_helpers.h> +#include "bpf_misc.h" + +struct { + __uint(type, BPF_MAP_TYPE_ARRAY); + __uint(max_entries, 1); + __type(key, __u32); + __type(value, __u32); +} map_array SEC(".maps"); + +SEC("socket") +__description("invalid map type for tail call") +__failure __msg("expected prog array map for tail call") +__failure_unpriv +__naked void invalid_map_for_tail_call (void ) +{ + asmvolatile (" \ +r2 = %[map_array] ll; \ +r3 = 0; \ +call %[bpf_tail_call]; \ +exit; \ +" : + : __imm(bpf_tail_call), +__imm_addr (map_array) + : __clobber_all); +} + +char _license[] SEC("license") = "GPL";
Signature · 1 line
2.43.0
Quoted 6 lines · Paul Chaignon
This patch adds a negative test case for the following verifier error.
expected prog array map for tail call
Acked-by Yonghong Song <[email protected]>Signed-off-by Paul Chaignon <[email protected]>
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 8 lines · On Mon, 7 Jul 2025 13:50:35 +0200 you wrote:
This patch adds a negative test case for the following verifier error.
expected prog array map for tail call
Acked-by Yonghong Song <[email protected]>Signed-off-by Paul Chaignon <[email protected]>[...]
Here is the summary with links:
- [bpf-next,v4] selftests/bpf: Negative test case for tail call map
https://git.kernel.org/bpf/bpf-next/c/192e3aa14529
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html