Enhance BPF global subprogs with argument tags
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
- v3 Latest10 patches 2 repliesApplied 10/10
- v210 patches 15 repliesSuperseded
- v113 patches 21 repliesSuperseded
Changes in v3 from the cover letter
- patch #10 improved by checking expected verifier error (Eduard);
Patches in v3 All 10 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/10 | bpf: abstract away global subprog arg preparation logic from reg state setupinclude/ include/ kernel/ +1 more | +64 | 0 replies | Applied |
| 2/10 | bpf: reuse btf_prepare_func_args() check for main program BTF validationinclude/ kernel/ kernel/ +3 more | +19 | 0 replies | Applied |
| 3/10 | bpf: prepare btf_prepare_func_args() for handling static subprogsinclude/ kernel/ kernel/ | +14 | 0 replies | Applied |
| 4/10 | bpf: move subprog call logic back to verifier.cinclude/ include/ kernel/ +1 more | +146 | 0 replies | Applied |
| 5/10 | bpf: reuse subprog argument parsing logic for subprog call checkskernel/ tools/ | +31 | 0 replies | Applied |
| 6/10 | bpf: support 'arg:xxx' btf_decl_tag-based hints for global subprog argskernel/ kernel/ | +42 | 0 replies | Applied |
| 7/10 | bpf: add support for passing dynptr pointer to global subprogkernel/ kernel/ | +30 | 2 replies | Applied |
| 8/10 | libbpf: add __arg_xxx macros for annotating global func argstools/ | +3 | 0 replies | Applied |
| 9/10 | selftests/bpf: add global subprog annotation teststools/ | +95 | 0 replies | Applied |
| 10/10 | selftests/bpf: add freplace of BTF-unreliable main prog testtools/ tools/ tools/ +1 more | +69 | 0 replies | Applied |
Reviews trailers per patch
All 10 patches have a Reviewed-by or Acked-by.
| Patch | Eduard Zingerman |
|---|---|
| 1/10 | A-b |
| 2/10 | A-b |
| 3/10 | A-b |
| 4/10 | A-b |
| 5/10 | A-b |
| 6/10 | A-b |
| 7/10 | A-b |
| 8/10 | A-b |
| 9/10 | A-b |
| 10/10 | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v3 bpf-next 00/10] Enhance BPF global subprogs with argument tags
This patch set adds verifier support for annotating user's global BPF subprog arguments with few commonly requested annotations, to improve global subprog verification experience.
These tags are:
- ability to annotate a special PTR_TO_CTX argument;
- ability to annotate a generic PTR_TO_MEM as non-null.
We utilize btf_decl_tag attribute for this and provide two helper macros as part of bpf_helpers.h in libbpf (patch #8).
Besides this we also add abilit to pass a pointer to dynptr into global subprog. This is done based on type name match (struct bpf_dynptr *). This allows to pass dynptrs into global subprogs, for use cases that deal with variable-sized generic memory pointers.
Big chunk of the patch set (patches #1 through #5) are various refactorings to make verifier internals around global subprog validation logic easier to extend and support long term, eliminating BTF parsing logic duplication, factoring out argument expectation definitions from BTF parsing, etc.
New functionality is added in patch #6 (ctx and non-null) and patch #7 (dynptr), extending global subprog checks with awareness for arg tags.
Patch #9 adds simple tests validating each of the added tags and dynptr argument passing.
Patch #10 adds a simple negative case for freplace programs to make sure that target BPF programs with "unreliable" BTF func proto cannot be freplaced.
v2->v3:
- patch #10 improved by checking expected verifier error (Eduard);v1->v2:
- dropped packet args for now (Eduard);
- added back unreliable=true detection for entry BPF programs (Eduard);
- improved subprog arg validation (Eduard);
- switched dynptr arg from tag to just type name based check (Eduard).
Andrii Nakryiko (10):
bpf: abstract away global subprog arg preparation logic from reg state
setup
bpf: reuse btf_prepare_func_args() check for main program BTF
validation
bpf: prepare btf_prepare_func_args() for handling static subprogs
bpf: move subprog call logic back to verifier.c
bpf: reuse subprog argument parsing logic for subprog call checks
bpf: support 'arg:xxx' btf_decl_tag-based hints for global subprog
args
bpf: add support for passing dynptr pointer to global subprog
libbpf: add __arg_xxx macros for annotating global func args selftests/bpf: add global subprog annotation tests selftests/bpf: add freplace of BTF-unreliable main prog test
include/linux/bpf.h | 7 +- include/linux/bpf_verifier.h | 29 +- kernel/bpf/btf.c | 282 +++++------------- kernel/bpf/verifier.c | 184 +++++++++--- tools/lib/bpf/bpf_helpers.h | 3 + .../selftests/bpf/prog_tests/fexit_bpf2bpf.c | 30 +- .../selftests/bpf/prog_tests/log_fixup.c | 4 +- .../selftests/bpf/prog_tests/verifier.c | 2 + .../selftests/bpf/progs/cgrp_kfunc_failure.c | 2 +- .../bpf/progs/freplace_unreliable_prog.c | 20 ++ .../selftests/bpf/progs/task_kfunc_failure.c | 2 +- .../selftests/bpf/progs/test_global_func5.c | 2 +- .../bpf/progs/verifier_btf_unreliable_prog.c | 20 ++ .../bpf/progs/verifier_global_subprogs.c | 99 +++++- 14 files changed, 416 insertions(+), 270 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/freplace_unreliable_prog.c create mode 100644 tools/testing/selftests/bpf/progs/verifier_btf_unreliable_prog.c
Signature · 1 line
2.34.1