public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] Detect and prune dead branches using intersection checks
@ 2026-04-15 16:07 Harishankar Vishwanathan
  2026-04-15 16:07 ` [PATCH bpf-next 1/2] bpf/verifier: Use intersection checks when simulating to detect dead branches Harishankar Vishwanathan
  2026-04-15 16:07 ` [PATCH bpf-next 2/2] selftests/bpf: Test for empty intersection of tnum and u64 Harishankar Vishwanathan
  0 siblings, 2 replies; 18+ messages in thread
From: Harishankar Vishwanathan @ 2026-04-15 16:07 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Eduard Zingerman, Paul Chaignon, Shung-Hsi Yu,
	Harishankar Vishwanathan, Srinivas Narayana, Santosh Nagarakatte

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(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2026-04-18  0:45 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-15 16:07 [PATCH bpf-next 0/2] Detect and prune dead branches using intersection checks Harishankar Vishwanathan
2026-04-15 16:07 ` [PATCH bpf-next 1/2] bpf/verifier: Use intersection checks when simulating to detect dead branches Harishankar Vishwanathan
2026-04-15 17:04   ` bot+bpf-ci
2026-04-15 19:02   ` Paul Chaignon
2026-04-16  1:10   ` Eduard Zingerman
2026-04-16 17:23     ` Eduard Zingerman
2026-04-16 23:13     ` Harishankar Vishwanathan
2026-04-16 23:33       ` Eduard Zingerman
2026-04-17  5:24         ` Eduard Zingerman
2026-04-17  5:34         ` Harishankar Vishwanathan
2026-04-17 21:17           ` Eduard Zingerman
2026-04-17 23:19             ` Eduard Zingerman
2026-04-18  0:38               ` Harishankar Vishwanathan
2026-04-18  0:45                 ` Eduard Zingerman
2026-04-18  0:22             ` Harishankar Vishwanathan
2026-04-15 16:07 ` [PATCH bpf-next 2/2] selftests/bpf: Test for empty intersection of tnum and u64 Harishankar Vishwanathan
2026-04-15 18:29   ` sashiko-bot
2026-04-16 17:51     ` Paul Chaignon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox