Detect and prune dead branches using intersection checks
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 16 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | bpf/verifier: Use intersection checks when simulating to detect dead brancheskernel/ | +219 | 15 replies | |
| 2/2 | selftests/bpf: Test for empty intersection of tnum and u64tools/ | +25 | 1 reply |
Reviews trailers per patch
1 of 2 patches has a Reviewed-by or Acked-by.
| Patch | Paul Chaignon |
|---|---|
| 1/2 | T-b A-b |
| 2/2 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH bpf-next 0/2] Detect and prune dead branches using intersection checks
This patchset improves the BPF verifier's dead branch detection and pruning by introducing intersection checks for the verifier's abstract domains (u64, s64, u32, s32, and tnum).
Previously, the verifier could detect only ill-formed ranges (e.g., umin > umax) to detect dead branches during simulation [1]. This patchset expands upon that by identifying situations where the abstract values across different domains for a given register no longer intersect. If there is no concrete integer value that simultaneously satisfies the bounds of all tracked domains, the verifier can safely deduce that the branch is dead code. As a proof of correctness, the C implementation for each of the 10 domain intersection checks has been formally verified against a logical specification using the Agni framework [2].
Patch 1 introduces reg_bounds_intersect() which implements intersection checks for all 10 domain pairs and uses this in simulate_both_branches_taken() to improve dead branch detection, and in reg_bounds_sync() to exit early on invalid inputs that have no intersection.
Patch 2 (Paul) adds an accompanying selftest that relies on an empty intersection between tnum and u64 state, something that is detectable only by the new logic.
[1] commit b254c6d816e5 ("bpf: Simulate branches to prune based on range violations")
[2] https://github.com/bpfverif/agni
Harishankar Vishwanathan (1):
bpf/verifier: Use intersection checks when simulating to detect dead
branches
Paul Chaignon (1):
selftests/bpf: Test for empty intersection of tnum and u64
kernel/bpf/verifier.c | 224 +++++++++++++++++- .../selftests/bpf/progs/verifier_bounds.c | 25 ++ 2 files changed, 244 insertions(+), 5 deletions(-)
Signature · 1 line
2.51.0