Skip to content

Unify subprog argument checks

Amery Hung bpf 3 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. v3 Latest11 patches 0 repliesApplied 11/11
  2. v211 patches 1 replySuperseded
  3. v112 patches 4 repliesSuperseded

Changes in v3 from the cover letter

- Remove the redundant dynptr register-type check from process_dynptr_func() after all callers begin using check_func_arg() (Sashiko)

Patches in v3 All 11 applied

#Subject and filesSizeRepliesApplied
1/11bpf: Fix kfunc BTF parameter lookups after wide argumentskernel/bpf/verifier.c+10 -100 repliesApplied
2/11bpf: Identify subprog calls in argument metadatakernel/bpf/verifier.c+23 -130 repliesApplied
3/11bpf: Build argument prototypes for subprog callsinclude/linux/bpf_verifier.h kernel/bpf/verifier.c+73 -330 repliesApplied
4/11bpf: Check subprog scalar arguments in the common pathkernel/bpf/verifier.c tools/testing/selftests/bpf/progs/aggregate_arg_func.c+7 -140 repliesApplied
5/11bpf: Check global subprog untrusted arguments in the common pathkernel/bpf/verifier.c+11 -80 repliesApplied
6/11bpf: Check subprog context arguments in the common pathkernel/bpf/verifier.c tools/testing/selftests/bpf/progs/test_global_func5.c+3 -140 repliesApplied
7/11bpf: Check subprog arena arguments in the common pathkernel/bpf/verifier.c+4 -140 repliesApplied
8/11bpf: Check subprog dynptr arguments in the common pathkernel/bpf/verifier.c tools/testing/selftests/bpf/progs/dynptr_fail.c+6 -280 repliesApplied
9/11bpf: Check global subprog BTF-ID arguments in the common pathkernel/bpf/verifier.c tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c+10 -250 repliesApplied
10/11bpf: Check global subprog memory arguments in the common pathinclude/linux/bpf_verifier.h kernel/bpf/verifier.c tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c +1 more+33 -330 repliesApplied
11/11bpf: Check all subprog arguments in the common pathkernel/bpf/verifier.c+11 -540 repliesApplied

Reviews trailers per patch

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

Read the v3 thread

Cover letter [PATCH bpf-next v3 00/11] Unify subprog argument checks

Hi,

Helper and kfunc calls now validate arguments through check_func_args(), while subprog calls still duplicate much of the same validation in btf_check_func_arg_match(). This makes common argument rules and diagnostics easy to change for one call kind without updating the other.

This series builds a temporary helper-style argument prototype from the subprog's cached BTF metadata, then moves each supported argument class to the common checker. The last patch removes the duplicate loop.

The series is organized as follows:

- Patch 1 fixes kfunc BTF parameter lookups after wide arguments.
- Patches 2-3 identify subprog calls in common metadata and generate the temporary argument prototype.
- Patches 4-9 move scalar, untrusted, context, arena, dynptr, and BTF-ID arguments to the common path.
- Patch 10 moves global subprog memory arguments and their packet-change check to the common path.
- Patch 11 removes the legacy loop and checks all subprog arguments through check_func_args().

This follows the helper/kfunc argument-checking consolidation:
https://lore.kernel.org/bpf/[email protected]/

v2 -> v3:
- Remove the redundant dynptr register-type check from process_dynptr_func() after all callers begin using check_func_arg() (Sashiko)

v1 -> v2:
- Extend patch 1 to fix the release and iterator BTF parameter lookups after wide arguments (Alexei)
- Keep subprog call metadata local to argument checking, leaving callers and helper/kfunc handling unchanged (Alexei)

Amery Hung (11):
bpf: Fix kfunc BTF parameter lookups after wide arguments
bpf: Identify subprog calls in argument metadata
bpf: Build argument prototypes for subprog calls
bpf: Check subprog scalar arguments in the common path
bpf: Check global subprog untrusted arguments in the common path
bpf: Check subprog context arguments in the common path
bpf: Check subprog arena arguments in the common path
bpf: Check subprog dynptr arguments in the common path
bpf: Check global subprog BTF-ID arguments in the common path
bpf: Check global subprog memory arguments in the common path
bpf: Check all subprog arguments in the common path

 include/linux/bpf_verifier.h                  |   6 +-
 kernel/bpf/verifier.c                         | 283 +++++++-----------
 .../selftests/bpf/progs/aggregate_arg_func.c  |   2 +-
 .../testing/selftests/bpf/progs/dynptr_fail.c |  11 +-
 .../selftests/bpf/progs/test_global_func5.c   |   2 +-
 .../bpf/progs/verifier_global_ptr_args.c      |   7 +-
 .../bpf/progs/verifier_global_subprogs.c      |   2 +-
 7 files changed, 129 insertions(+), 184 deletions(-)
Signature · 1 line
2.52.0