selftests/bpf: Test case for lacking CFI stub functions.
authorKui-Feng Lee <thinker.li@gmail.com>
Thu, 22 Feb 2024 02:11:05 +0000 (18:11 -0800)
committerMartin KaFai Lau <martin.lau@kernel.org>
Thu, 22 Feb 2024 20:26:41 +0000 (12:26 -0800)
commite9bbda13a7b876451285ab15fb600b809e5e2290
tree5c5951094ff327b9e52343e25707d5cc944f2fdb
parent3e0008336ae3153fb89b1a15bb877ddd38680fe6
selftests/bpf: Test case for lacking CFI stub functions.

Ensure struct_ops rejects the registration of struct_ops types without
proper CFI stub functions.

bpf_test_no_cfi.ko is a module that attempts to register a struct_ops type
called "bpf_test_no_cfi_ops" with cfi_stubs of NULL and non-NULL value.
The NULL one should fail, and the non-NULL one should succeed. The module
can only be loaded successfully if these registrations yield the expected
results.

Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com>
Link: https://lore.kernel.org/r/20240222021105.1180475-3-thinker.li@gmail.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
tools/testing/selftests/bpf/Makefile
tools/testing/selftests/bpf/bpf_test_no_cfi/Makefile [new file with mode: 0644]
tools/testing/selftests/bpf/bpf_test_no_cfi/bpf_test_no_cfi.c [new file with mode: 0644]
tools/testing/selftests/bpf/prog_tests/test_struct_ops_no_cfi.c [new file with mode: 0644]
tools/testing/selftests/bpf/testing_helpers.c
tools/testing/selftests/bpf/testing_helpers.h