Make check_func_arg type checks table driven
Status from this message: Applied to bpf-next. Thanks!
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest posting 2/211 patches 5 repliesApplied
- v4 posting 1/211 patches 0 repliesSuperseded
- v311 patches 6 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 | 11 patches | 12 replies | Superseded |
Changes in v4 from the cover letter
- Output the desired type on BTF ID mismatch (Martin)
Patches in v4 posting 2/2 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/11 | btf: make btf_set_contains take a const pointerinclude/ kernel/ | +2 | 0 replies | |
| 2/11 | bpf: check scalar or invalid register in check_helper_mem_accesskernel/ | +11 | 0 replies | |
| 3/11 | btf: Add BTF_ID_LIST_SINGLE macroinclude/ tools/ | +16 | 0 replies | |
| 4/11 | bpf: allow specifying a BTF ID per argument in function protosinclude/ kernel/ kernel/ +6 more | +58 | 0 replies | |
| 5/11 | bpf: make BTF pointer type checking generickernel/ | +20 | 0 replies | |
| 6/11 | bpf: make reference tracking generickernel/ | +10 | 0 replies | |
| 7/11 | bpf: make context access check generickernel/ | +4 | 0 replies | |
| 8/11 | bpf: set meta->raw_mode for pointers close to usekernel/ | +5 | 0 replies | |
| 9/11 | bpf: check ARG_PTR_TO_SPINLOCK register type in check_func_argkernel/ | +14 | 0 replies | |
| 10/11 | bpf: hoist type checking for nullable arg typeskernel/ | +30 | 0 replies | |
| 11/11 | bpf: use a table to drive helper arg type checksinclude/ kernel/ | +110 | 5 replies |
Reviews trailers per patch
All 11 patches have a Reviewed-by or Acked-by.
| Patch | Andrii Nakryiko | Martin KaFai Lau |
|---|---|---|
| 1/11 | A-b | |
| 2/11 | A-b | |
| 3/11 | A-b | |
| 4/11 | A-b | |
| 5/11 | A-b | |
| 6/11 | A-b | A-b |
| 7/11 | A-b | |
| 8/11 | A-b | |
| 9/11 | A-b | |
| 10/11 | A-b | A-b |
| 11/11 | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH RESEND bpf-next v4 00/11] Make check_func_arg type checks table driven
I'm not sure why, but I missed sending the patchset to netdev@ last week. I guess that is why it's slipped through the cracks.
Changes in v4:
- Output the desired type on BTF ID mismatch (Martin)
Changes in v3:
- Fix BTF_ID_LIST_SINGLE if BTF is disabled (Martin)
- Drop incorrect arg_btf_id in bpf_sk_storage.c (Martin)
- Check for arg_btf_id in check_func_proto (Martin)
- Drop incorrect PTR_TO_BTF_ID from fullsock_types (Martin)
- Introduce btf_seq_file_ids in bpf_trace.c to reduce duplication
Changes in v2:
- Make the series stand alone (Martin)
- Drop incorrect BTF_SET_START fix (Andrii)
- Only support a single BTF ID per argument (Martin)
- Introduce BTF_ID_LIST_SINGLE macro (Andrii)
- Skip check_ctx_reg iff register is NULL
- Change output of check_reg_type slightly, to avoid touching tests
Original cover letter:
Currently, check_func_arg has this pretty gnarly if statement that compares the valid arg_type with the actualy reg_type. Sprinkled in-between are checks for register_is_null, to short circuit these tests if we're dealing with a nullable arg_type. There is also some code for later bounds / access checking hidden away in there.
This series of patches refactors the function into something like this:
if (reg_is_null && arg_type_is_nullable)
skip type checkingdo type checking, including BTF validation
do bounds / access checking
The type checking is now table driven, which makes it easy to extend the acceptable types. Maybe more importantly, using a table makes it easy to provide more helpful verifier output (see the last patch).
Lorenz Bauer (11):
btf: make btf_set_contains take a const pointer
bpf: check scalar or invalid register in check_helper_mem_access
btf: Add BTF_ID_LIST_SINGLE macro
bpf: allow specifying a BTF ID per argument in function protos
bpf: make BTF pointer type checking generic
bpf: make reference tracking generic
bpf: make context access check generic
bpf: set meta->raw_mode for pointers close to use
bpf: check ARG_PTR_TO_SPINLOCK register type in check_func_arg
bpf: hoist type checking for nullable arg types
bpf: use a table to drive helper arg type checks
include/linux/bpf.h | 21 +- include/linux/btf_ids.h | 8 + kernel/bpf/bpf_inode_storage.c | 8 +- kernel/bpf/btf.c | 15 +- kernel/bpf/stackmap.c | 5 +- kernel/bpf/verifier.c | 338 ++++++++++++++++++--------------- kernel/trace/bpf_trace.c | 15 +- net/core/bpf_sk_storage.c | 8 +- net/core/filter.c | 31 +-- net/ipv4/bpf_tcp_ca.c | 19 +- tools/include/linux/btf_ids.h | 8 + 11 files changed, 239 insertions(+), 237 deletions(-)
Signature · 1 line
2.25.1