bpf: Allow void return type for global subprogs
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
- v6 Latest5 patches 2 repliesApplied 5/5
- v55 patches 8 repliesSuperseded
- v44 patches 5 repliesSuperseded
Earlier versions · 3
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v3 | 2 patches | 7 replies | Superseded | |
| v2 | 2 patches | 0 replies | Superseded | |
| v1 | 1 patch | 4 replies | Superseded |
Changes in v6 from the cover letter
Patches in v6 All 5 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | bpf: Factor out program return value calculationinclude/ kernel/ | +126 | 0 replies | Applied |
| 2/5 | bpf: Extract program_returns_void() for claritykernel/ | +36 | 0 replies | Applied |
| 3/5 | bpf: extract check_global_subprog_return_code() for claritykernel/ | +44 | 2 replies | Applied |
| 4/5 | bpf: Allow void global functions in the verifierkernel/ kernel/ tools/ +1 more | +60 | 0 replies | Applied |
| 5/5 | selftests: bpf: Add tests for void global subprogstools/ tools/ tools/ +4 more | +111 | 0 replies | Applied |
Reviews trailers per patch
3 of 5 patches have a Reviewed-by or Acked-by.
| Patch | Eduard Zingerman |
|---|---|
| 1/5 | A-b |
| 2/5 | |
| 3/5 | |
| 4/5 | A-b |
| 5/5 | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH bpf-next v6 0/5] bpf: Allow void return type for global subprogs
Global subprogs are currently not allowed to return void. Adjust verifier logic to allow global functions with a void return type. Exception callbacks are excluded from this change, and still require a scalar return type.
Adding additional logic for void globals significantly complicates check_return_code(), mainly because of how the new feature interacts with bpf_throw(). To avoid complicating the code, refactor the return value range validation logic into two separate functions, one for program exits through BPF_EXIT and one for program exits through bpf_throw(). The changes are non-functional.
Also adjust existing selftests that were ensuring that global subprogs with void return types fail to verify. These tests should now load successfully.
Patches 1-3 refactor check_return_code into two separate functions, one for BPF_EXIT and one for bpf_throw(). No functional changes.
Patches 4-5 enable void globals in the verifier and add additional selftests.
v5 -> v6
(https://lore.kernel.org/bpf/[email protected]/)
Patch 1:
- Removed unused variables (kernel test robot)
- Add break; on empty default to suppress warning (kernel test robot)
- Added explanation on why change in switch statement for BPF_PROG_TYPE_TRACING in check_return_code is a no-op
Patches 2/3:
- Added From: tags to Eduard's patches and changed my Reviewed-by to Signed-off-by to properly denote patch route (submitting-patches.rst)
- Renamed check_subprogram_return_code for into check_global_subprog_return_code (Eduard)
Patch 4:
- Remove unnecessary subprog_is_global() check in check_return_code (Eduard)
- Fix indentation on patch 4 (AI)
Patch 5:
- Fix unused data in selftests (Eduard)
v4 -> v5
(https://lore.kernel.org/bpf/[email protected]/)
- Split value validation logic from throw/nonthrow to main prog/subprog (Eduard)
- Turn return_retval_range() to bool and incorporate return_32bit in retval (Eduard)
- Adjust if-else chain in return_retval_range for cgroup programs into switch statement to bring it in line with the other program types
v3 -> v4
(https://lore.kernel.org/bpf/[email protected]/)
- Factor out bpf_throw() return value validation logic into its own function (Eduard)
- Validate the range of bpf_throw() return values from void globals (Eduard)
- Move new selftest to verifier_global_subprogs.c (Eduard)
- Remove unnecessary verifier_bug_if() statements (Eduard)
- Add new test to ensure void globals can call bpf_throw
v2 -> v3
(https://lore.kernel.org/bpf/[email protected]/)
- Allow freplace for global programs that return void and add selftests (Kumar)
v1 -> v2
(https://lore.kernel.org/bpf/[email protected]/)
- Only mark R0 as valid for non-void global functions (AI)
- Rename subprog_is_void to subprog_returns_void (Kumar)
- Add test that R0 is invalid after calling a void global (Alexei)
- Add check to ensure exception callbacks do not return void and associated selftest
Eduard Zingerman (2):
bpf: Extract program_returns_void() for clarity
bpf: extract check_global_subprog_return_code() for clarity
Emil Tsalapatis (3):
bpf: Factor out program return value calculation
bpf: Allow void global functions in the verifier
selftests: bpf: Add tests for void global subprogs
include/linux/bpf_verifier.h | 1 + kernel/bpf/btf.c | 7 +- kernel/bpf/verifier.c | 349 ++++++++++++------ .../selftests/bpf/prog_tests/exceptions.c | 1 + .../selftests/bpf/prog_tests/fexit_bpf2bpf.c | 24 ++ .../testing/selftests/bpf/progs/exceptions.c | 14 + .../selftests/bpf/progs/exceptions_fail.c | 35 +- .../bpf/progs/freplace_int_with_void.c | 11 + .../selftests/bpf/progs/freplace_void.c | 10 + .../selftests/bpf/progs/test_global_func7.c | 2 +- .../bpf/progs/verifier_global_subprogs.c | 19 + 11 files changed, 344 insertions(+), 129 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/freplace_int_with_void.c create mode 100644 tools/testing/selftests/bpf/progs/freplace_void.c
Signature · 1 line
2.49.0