Somehow, bpf_tcp_ca misses a stub function.
Will add it in the next version.
On 2/16/24 10:40, Kui-Feng Lee wrote:
It fails on CI.
I am fixing it.
On 2/15/24 18:03, thinker.li@xxxxxxxxx wrote:
From: Kui-Feng Lee <thinker.li@xxxxxxxxx>
Recently, cfi_stubs were introduced. However, existing struct_ops
types that are not in the upstream may not be aware of this, resulting
in kernel crashes. By rejecting struct_ops types that do not provide
cfi_stubs properly during registration, these crashes can be avoided.
---
Changes from v1:
- Check *(void **)(cfi_stubs + moff) to make sure stub functions are
provided for every operator.
- Add a test case to ensure that struct_ops rejects incomplete
cfi_stub.
v1:
https://lore.kernel.org/all/20240215022401.1882010-1-thinker.li@xxxxxxxxx/
Kui-Feng Lee (2):
bpf: Check cfi_stubs before registering a struct_ops type.
selftests/bpf: Test case for lacking CFI stub functions.
kernel/bpf/bpf_struct_ops.c | 14 +++
tools/testing/selftests/bpf/Makefile | 10 +-
.../selftests/bpf/bpf_test_no_cfi/Makefile | 19 ++++
.../bpf/bpf_test_no_cfi/bpf_test_no_cfi.c | 93 +++++++++++++++++++
.../bpf/prog_tests/test_struct_ops_no_cfi.c | 31 +++++++
tools/testing/selftests/bpf/testing_helpers.c | 4 +-
tools/testing/selftests/bpf/testing_helpers.h | 2 +
7 files changed, 170 insertions(+), 3 deletions(-)
create mode 100644 tools/testing/selftests/bpf/bpf_test_no_cfi/Makefile
create mode 100644
tools/testing/selftests/bpf/bpf_test_no_cfi/bpf_test_no_cfi.c
create mode 100644
tools/testing/selftests/bpf/prog_tests/test_struct_ops_no_cfi.c