libbpf: Reject local struct_ops bitfields before data access
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest2 patches 1 replyIn review 1 of 2 applied
- v12 patches 1 replySuperseded
Changes in v3 from the cover letter
- Restore the local bitfield check from v1.
- Drop general offset validation and the bpftool changes, which covered malformed BTF outside.
- Describe the local struct_ops type and absent kernel member.
- Keep the negative test and check the load result before the diagnostic.
Patches in v3 1 of 2 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | libbpf: Reject local struct_ops bitfields before data accesstools/ | +7 | 1 reply | Applied |
| 2/2 | selftests/bpf: Test local struct_ops bitfield rejectiontools/ tools/ | +39 | 0 replies |
Reviews trailers per patch
1 of 2 patches has a Reviewed-by or Acked-by.
| Patch | Amery Hung |
|---|---|
| 1/2 | R-b |
| 2/2 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH bpf v3 0/2] libbpf: Reject local struct_ops bitfields before data access
A local struct_ops type can contain a bitfield absent from the corresponding kernel BTF type. libbpf calculated the member data pointer from the encoded BTF member offset before rejecting the bitfield. The absent member zero check could then read outside the local struct_ops data and crash libbpf.
Patch 1 rejects local bitfields before calculating the member data pointer. Patch 2 adds a negative test for a local bitfield absent from the kernel BTF type.
AI assistance was used to prepare the messages. I independently reviewed the code and test results.
Changes since v2:
- Restore the local bitfield check from v1.
- Drop general offset validation and the bpftool changes, which covered malformed BTF outside.
- Describe the local struct_ops type and absent kernel member.
- Keep the negative test and check the load result before the diagnostic.
v2: https://lore.kernel.org/bpf/[email protected]/
v1: https://lore.kernel.org/bpf/[email protected]/
Mingpei CAO (2):
libbpf: Reject local struct_ops bitfields before data access selftests/bpf: Test local struct_ops bitfield rejection
tools/lib/bpf/libbpf.c | 9 ++++-- .../bpf/prog_tests/test_struct_ops_module.c | 32 +++++++++++++++++++ .../selftests/bpf/progs/struct_ops_module.c | 7 ++++ 3 files changed, 46 insertions(+), 2 deletions(-)
base-commit: ee363e055895364039bf28348ff13c615afad4ba
Signature · 1 line
2.43.0