Skip to content

Check cfi_stubs before registering a struct_ops type.

[email protected] bpf 5 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest2 patches 1 replyApplied 2/2
  2. v43 patches 3 repliesSuperseded
  3. v33 patches 2 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v22 patches2 repliesSuperseded
v11 patch3 repliesSuperseded

Changes in v5 from the cover letter

- Remove changes of check_member.

- Remove checks of the pointers in cfi_stubs[].

Patches in v5 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: Check cfi_stubs before registering a struct_ops type.kernel/bpf/bpf_struct_ops.c+5 -00 repliesApplied
2/2selftests/bpf: Test case for lacking CFI stub functions.tools/testing/selftests/bpf/Makefile tools/testing/selftests/bpf/bpf_test_no_cfi/Makefile tools/testing/selftests/bpf/bpf_test_no_cfi/bpf_test_no_cfi.c +3 more+154 -31 replyApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH bpf-next v5 0/2] Check cfi_stubs before registering a struct_ops type.

From: Kui-Feng Lee <[email protected]>

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 v4:

- Remove changes of check_member.

- Remove checks of the pointers in cfi_stubs[].

Changes from v3:

- Remove CFI stub function for get_info.

- Allow passing NULL prog arg to check_member of struct bpf_struct_ops type.

- Call check_member to determines if a CFI stub function should be defined for an operator.

Changes from v2:

- Add a stub function for get_info of struct tcp_congestion_ops.

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.

v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

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                   |  5 ++
 tools/testing/selftests/bpf/Makefile          | 10 ++-
 .../selftests/bpf/bpf_test_no_cfi/Makefile    | 19 +++++
 .../bpf/bpf_test_no_cfi/bpf_test_no_cfi.c     | 84 +++++++++++++++++++
 .../bpf/prog_tests/test_struct_ops_no_cfi.c   | 38 +++++++++
 tools/testing/selftests/bpf/testing_helpers.c |  4 +-
 tools/testing/selftests/bpf/testing_helpers.h |  2 +
 7 files changed, 159 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
Signature · 1 line
2.34.1