]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: Test ambiguous associated struct_ops
authorAmery Hung <ameryhung@gmail.com>
Wed, 3 Dec 2025 23:37:47 +0000 (15:37 -0800)
committerAndrii Nakryiko <andrii@kernel.org>
Sat, 6 Dec 2025 00:17:58 +0000 (16:17 -0800)
commit04fd12df4e05dd6fd3017b637f6fbc9da10b4e65
tree7c385a945e5f39875943c9b29473df20589f6b0f
parent33a165f9c2c1b9ddceaaccc356ce841baf1a08a2
selftests/bpf: Test ambiguous associated struct_ops

Add a test to make sure implicit struct_ops association does not
break backward compatibility nor return incorrect struct_ops.
struct_ops programs should still be allowed to be reused in
different struct_ops map. The associated struct_ops map set implicitly
however will be poisoned. Trying to read it through the helper
bpf_prog_get_assoc_struct_ops() should result in a NULL pointer.

While recursion of test_1() cannot happen due to the associated
struct_ops being ambiguois, explicitly check for it to prevent stack
overflow if the test regresses.

Signed-off-by: Amery Hung <ameryhung@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20251203233748.668365-6-ameryhung@gmail.com
tools/testing/selftests/bpf/prog_tests/test_struct_ops_assoc.c
tools/testing/selftests/bpf/progs/struct_ops_assoc_reuse.c [new file with mode: 0644]