BPF verifier retval logic fixes
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
- v5 Latest11 patches 0 repliesApplied 11/11
- v411 patches 1 replySuperseded
- v310 patches 9 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 | 10 patches | 10 replies | Superseded | |
| v1 | 10 patches | 16 replies | Superseded |
Changes in v5 from the cover letter
- fix timer_bad_ret test on no-alu32 flavor (CI);
Patches in v5 All 11 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/11 | bpf: rearrange bpf_func_state fields to save a bit of memoryinclude/ | +2 | 0 replies | Applied |
| 2/11 | bpf: provide correct register name for exception callback retval checkkernel/ tools/ tools/ | +8 | 0 replies | Applied |
| 3/11 | bpf: enforce precision of R0 on callback returnkernel/ | +7 | 0 replies | Applied |
| 4/11 | bpf: enforce exact retval range on subprog/callback exitinclude/ kernel/ | +28 | 0 replies | Applied |
| 5/11 | selftests/bpf: add selftest validating callback result is enforcedtools/ | +50 | 0 replies | Applied |
| 6/11 | bpf: enforce precise retval range on program exitkernel/ tools/ tools/ +6 more | +40 | 0 replies | Applied |
| 7/11 | bpf: unify async callback and program retval checkskernel/ | +12 | 0 replies | Applied |
| 8/11 | bpf: enforce precision of R0 on program/async callback returnkernel/ | +4 | 0 replies | Applied |
| 9/11 | selftests/bpf: validate async callback return value check correctnesstools/ | +28 | 0 replies | Applied |
| 10/11 | selftests/bpf: adjust global_func15 test to validate prog exit precisiontools/ | +32 | 0 replies | Applied |
| 11/11 | bpf: simplify tnum output if a fully known constantkernel/ kernel/ tools/ +2 more | +17 | 0 replies | Applied |
Reviews trailers per patch
All 11 patches have a Reviewed-by or Acked-by.
| Patch | Eduard Zingerman | Shung-Hsi Yu |
|---|---|---|
| 1/11 | A-b | |
| 2/11 | A-b | A-b |
| 3/11 | A-b | A-b |
| 4/11 | A-b | A-b |
| 5/11 | A-b | A-b |
| 6/11 | A-b | A-b |
| 7/11 | A-b | A-b |
| 8/11 | A-b | |
| 9/11 | A-b | |
| 10/11 | 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 v5 bpf-next 00/11] BPF verifier retval logic fixes
This patch set fixes BPF verifier logic around validating and enforcing return values for BPF programs that have specific range of expected return values. Both sync and async callbacks have similar logic and are fixes as well. A few tests are added that would fail without the fixes in this patch set.
Also, while at it, we update retval checking logic to use smin/smax range instead of tnum, avoiding future potential issues if expected range cannot be represented precisely by tnum (e.g., [0, 2] is not representable by tnum and is treated as [0, 3]).
There is a little bit of refactoring to unify async callback and program exit logic to avoid duplication of checks as much as possible.
v4->v5:
- fix timer_bad_ret test on no-alu32 flavor (CI);v3->v4:
- add back bpf_func_state rearrangement patch;
- simplified patch #4 as suggested (Shung-Hsi);v2->v3:
- more carefullly switch from umin/umax to smin/smax;v1->v2:
- drop tnum from retval checks (Eduard);
- use smin/smax instead of umin/umax (Alexei).
Andrii Nakryiko (11):
bpf: rearrange bpf_func_state fields to save a bit of memory
bpf: provide correct register name for exception callback retval check
bpf: enforce precision of R0 on callback return
bpf: enforce exact retval range on subprog/callback exit selftests/bpf: add selftest validating callback result is enforced
bpf: enforce precise retval range on program exit
bpf: unify async callback and program retval checks
bpf: enforce precision of R0 on program/async callback return selftests/bpf: validate async callback return value check correctness selftests/bpf: adjust global_func15 test to validate prog exit
precision
bpf: simplify tnum output if a fully known constant
include/linux/bpf_verifier.h | 9 +- kernel/bpf/log.c | 13 ++ kernel/bpf/tnum.c | 6 - kernel/bpf/verifier.c | 120 ++++++++++-------- .../selftests/bpf/progs/exceptions_assert.c | 2 +- .../selftests/bpf/progs/exceptions_fail.c | 2 +- .../selftests/bpf/progs/test_global_func15.c | 34 ++++- .../selftests/bpf/progs/timer_failure.c | 36 ++++-- .../selftests/bpf/progs/user_ringbuf_fail.c | 2 +- .../bpf/progs/verifier_cgroup_inv_retcode.c | 8 +- .../bpf/progs/verifier_direct_packet_access.c | 2 +- .../selftests/bpf/progs/verifier_int_ptr.c | 2 +- .../bpf/progs/verifier_netfilter_retcode.c | 2 +- .../selftests/bpf/progs/verifier_stack_ptr.c | 4 +- .../bpf/progs/verifier_subprog_precision.c | 50 ++++++++ 15 files changed, 212 insertions(+), 80 deletions(-)
Signature · 1 line
2.34.1