]> www.infradead.org Git - users/jedix/linux-maple.git/commit
selftests/bpf: Test returning referenced kptr from struct_ops programs
authorAmery Hung <amery.hung@bytedance.com>
Mon, 17 Feb 2025 19:06:40 +0000 (11:06 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 18 Feb 2025 02:47:27 +0000 (18:47 -0800)
commitaf17bad9fb2aed949fd56d71558cf962dfda1705
treeee9769f63c843ae1606b660b8fa82557c17dfcf2
parent8d9f547f74c7b984dd903c4ffec026f2b2d46c58
selftests/bpf: Test returning referenced kptr from struct_ops programs

Test struct_ops programs returning referenced kptr. When the return type
of a struct_ops operator is pointer to struct, the verifier should
only allow programs that return a scalar NULL or a non-local kptr with the
correct type in its unmodified form.

Signed-off-by: Amery Hung <amery.hung@bytedance.com>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Acked-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://lore.kernel.org/r/20250217190640.1748177-6-ameryhung@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/test_struct_ops_kptr_return.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/struct_ops_kptr_return.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/struct_ops_kptr_return_fail__invalid_scalar.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/struct_ops_kptr_return_fail__local_kptr.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/struct_ops_kptr_return_fail__nonzero_offset.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/struct_ops_kptr_return_fail__wrong_type.c [new file with mode: 0644]
tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
tools/testing/selftests/bpf/test_kmods/bpf_testmod.h