Skip to content

Unify helper and kfunc call_arg_meta

Amery Hung bpf 2 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. v2 Latest7 patches 0 repliesApplied 7/7
  2. v14 patches 9 repliesSuperseded

Changes in v2 from the cover letter

- Fix patch 2: ARG_PTR_TO_MAP_VALUE | MEM_UNINIT should also accept raw mode
- Add patch 3: making check_func_arg() less verbose
- Add patch 5: a selftest testing a preexisting OOB access bug when 0 is passed to a kfunc's {rdwr,rdonly}_buf_size argument
- Add patch 6: dropping pkt_access from bpf_call_arg_meta

Patches in v2 All 7 applied

#Subject and filesSizeRepliesApplied
1/7bpf: Remove dynptr check in check_stack_range_initialized()kernel/bpf/verifier.c tools/testing/selftests/bpf/progs/dynptr_fail.c+2 -270 repliesApplied
2/7bpf: Factor out raw_mode-related fields in bpf_call_arg_metainclude/linux/bpf_verifier.h kernel/bpf/verifier.c+36 -310 repliesApplied
3/7bpf: Pass argno to callees in check_func_arg() instead of argno_from_reg(regno)kernel/bpf/verifier.c+17 -190 repliesApplied
4/7bpf: Unify helper and kfunc allocation-size argument handlinginclude/linux/bpf_verifier.h kernel/bpf/verifier.c tools/testing/selftests/bpf/prog_tests/kfunc_call.c+55 -430 repliesApplied
5/7selftests/bpf: Test kfunc returning zero-sized allocation buffertools/testing/selftests/bpf/prog_tests/kfunc_call.c tools/testing/selftests/bpf/progs/kfunc_call_fail.c+28 -00 repliesApplied
6/7bpf: Drop redundant pkt_access from bpf_call_arg_metakernel/bpf/verifier.c+4 -60 repliesApplied
7/7bpf: Unify helper and kfunc call argument metainclude/linux/bpf_verifier.h kernel/bpf/cfg.c kernel/bpf/verifier.c+62 -720 repliesApplied

Reviews trailers per patch

4 of 7 patches have a Reviewed-by or Acked-by.

PatchEduard Zingerman
1/7A-b
2/7A-b
3/7
4/7A-b
5/7
6/7
7/7A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH bpf-next v2 0/7] Unify helper and kfunc call_arg_meta

Hi all,

I am working toward unifying helper and kfunc handling in the verifier. Historically, kfunc verification was mostly done separately from helper. This causes code/logic duplication and may introduce subtle bugs as the same checks are implemnented differently.

To address this, I plan to unify function call verification, which will operate on a common function call descriptor bpf_func_proto.

As the first step, this patchset merges bpf_{kfunc_}call_arg_meta of kfunc and helepr. The structure is used as a scratch pad for different helper/kfunc verification mechanisms. The previous object tracking refactor patchset has unified some of them. This patch handles the rest and finally merge the two different structures.

The next step will be generating bpf_func_proto for kfunc before the main verification loop and align kfunc and helper argument types.

Then hopefully helper and kfunc can go throguh the same call verification path.

Changelog

v1 -> v2
- Fix patch 2: ARG_PTR_TO_MAP_VALUE | MEM_UNINIT should also accept raw mode
- Add patch 3: making check_func_arg() less verbose
- Add patch 5: a selftest testing a preexisting OOB access bug when 0 is passed to a kfunc's {rdwr,rdonly}_buf_size argument
- Add patch 6: dropping pkt_access from bpf_call_arg_meta

Amery Hung (7):
bpf: Remove dynptr check in check_stack_range_initialized()
bpf: Factor out raw_mode-related fields in bpf_call_arg_meta
bpf: Pass argno to callees in check_func_arg() instead of
argno_from_reg(regno)
bpf: Unify helper and kfunc allocation-size argument handling selftests/bpf: Test kfunc returning zero-sized allocation buffer
bpf: Drop redundant pkt_access from bpf_call_arg_meta
bpf: Unify helper and kfunc call argument meta

 include/linux/bpf_verifier.h                  |  54 +++-
 kernel/bpf/cfg.c                              |   2 +-
 kernel/bpf/verifier.c                         | 306 ++++++++----------
 .../selftests/bpf/prog_tests/kfunc_call.c     |   3 +-
 .../testing/selftests/bpf/progs/dynptr_fail.c |   4 +-
 .../selftests/bpf/progs/kfunc_call_fail.c     |  27 ++
 6 files changed, 201 insertions(+), 195 deletions(-)
Signature · 1 line
2.52.0