Add precision propagation for subprogs and callbacks
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 0 repliesApplied 10/10
- v210 patches 2 repliesSuperseded
- v110 patches 26 repliesSuperseded
Changes in v3 from the cover letter
- drop bitcnt and ifs from bt_xxx() helpers (Alexei);
Patches in v3 All 10 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/10 | veristat: add -t flag for adding BPF_F_TEST_STATE_FREQ program flagtools/ | +9 | 0 replies | Applied |
| 2/10 | bpf: mark relevant stack slots scratched for register read instructionskernel/ | +3 | 0 replies | Applied |
| 3/10 | bpf: encapsulate precision backtracking bookkeepinginclude/ kernel/ | +196 | 0 replies | Applied |
| 4/10 | bpf: improve precision backtrack logginginclude/ kernel/ tools/ | +128 | 0 replies | Applied |
| 5/10 | bpf: maintain bitmasks across all active frames in __mark_chain_precisionkernel/ tools/ | +62 | 0 replies | Applied |
| 6/10 | bpf: fix propagate_precision() logic for inner frameskernel/ | +35 | 0 replies | Applied |
| 7/10 | bpf: fix mark_all_scalars_precise use in mark_chain_precisionkernel/ tools/ | +18 | 0 replies | Applied |
| 8/10 | bpf: support precision propagation in the presence of subprogskernel/ | +143 | 0 replies | Applied |
| 9/10 | selftests/bpf: add precision propagation tests in the presence of subprogstools/ tools/ tools/ | +542 | 0 replies | Applied |
| 10/10 | selftests/bpf: revert iter test subprog precision workaroundtools/ | +11 | 0 replies | Applied |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.
Cover letter [PATCH v3 bpf-next 00/10] Add precision propagation for subprogs and callbacks
As more and more real-world BPF programs become more complex
and increasingly use subprograms (both static and global), scalar precision tracking and its (previously weak) support for BPF subprograms (and callbacks as a special case of that) is becoming more and more of an issue and limitation. Couple that with increasing reliance on state equivalence (BPF open-coded iterators have a hard requirement for state equivalence to converge and successfully validate loops), and it becomes pretty critical to address this limitation and make precision tracking universally supported for BPF programs of any complexity and composition.
This patch set teaches BPF verifier to support SCALAR precision backpropagation across multiple frames (for subprogram calls and callback simulations) and addresses most practical situations (SCALAR stack loads/stores using registers other than r10 being the last remaining limitation, though thankfully rarely used in practice).
Main logic is explained in details in patch #8. The rest are preliminary preparations, refactorings, clean ups, and fixes. See respective patches for details.
Patch #8 has also veristat comparison of results for selftests, Cilium, and some of Meta production BPF programs before and after these changes.
v2->v3:
- drop bitcnt and ifs from bt_xxx() helpers (Alexei);v1->v2:
- addressed review feedback form Alexei, adjusted commit messages, comments,
added verbose(), WARN_ONCE(), etc;
- re-ran all the tests and veristat on selftests, cilium, and meta-internal
code: no new changes and no kernel warnings.
Andrii Nakryiko (10):
veristat: add -t flag for adding BPF_F_TEST_STATE_FREQ program flag
bpf: mark relevant stack slots scratched for register read
instructions
bpf: encapsulate precision backtracking bookkeeping
bpf: improve precision backtrack logging
bpf: maintain bitmasks across all active frames in
__mark_chain_precision
bpf: fix propagate_precision() logic for inner frames
bpf: fix mark_all_scalars_precise use in mark_chain_precision
bpf: support precision propagation in the presence of subprogs selftests/bpf: add precision propagation tests in the presence of
subprogs
selftests/bpf: revert iter test subprog precision workaround
include/linux/bpf_verifier.h | 27 +- kernel/bpf/verifier.c | 622 +++++++++++++----- .../selftests/bpf/prog_tests/verifier.c | 2 + tools/testing/selftests/bpf/progs/bpf_misc.h | 4 + tools/testing/selftests/bpf/progs/iters.c | 26 +- .../bpf/progs/verifier_subprog_precision.c | 536 +++++++++++++++ .../testing/selftests/bpf/verifier/precise.c | 107 +-- tools/testing/selftests/bpf/veristat.c | 9 + 8 files changed, 1111 insertions(+), 222 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/verifier_subprog_precision.c
Signature · 1 line
2.34.1