From: Eduard Zingerman <eddyz87@gmail.com>
To: Harishankar Vishwanathan <harishankar.vishwanathan@gmail.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Paul Chaignon <paul.chaignon@gmail.com>,
Shung-Hsi Yu <shung-hsi.yu@suse.com>,
Srinivas Narayana <srinivas.narayana@rutgers.edu>,
Santosh Nagarakatte <santosh.nagarakatte@rutgers.edu>
Subject: Re: [PATCH bpf-next 1/2] bpf/verifier: Use intersection checks when simulating to detect dead branches
Date: Thu, 16 Apr 2026 22:24:37 -0700 [thread overview]
Message-ID: <8c3071d259e04aa6d0c20c7bb4e5bd31fc5335e5.camel@gmail.com> (raw)
In-Reply-To: <f79d58337ec3628a52d41a09e2c35e598ab656f4.camel@gmail.com>
On Thu, 2026-04-16 at 16:33 -0700, Eduard Zingerman wrote:
[...]
> Could you please comment about the witness idea?
> Suppose reg_bounds_sync() is modified to preserve the properties I
> described above, would it be sufficient to check two candidates:
> tmin and tnum_step(tmin) to identify a register in an invalid state?
Actually, the witness search procedure is probably more involved than that.
Something along the following lines (ignoring 32-bit ranges for now):
- case a. s64 range does not cross the sign boundary:
- w := min(umin_value, (u64)smin_value)
- w := w if w in tnum else tnum_step(tnum, w)
- case b. s64 range crosses the sign boundary:
- if u64 range intersects with lower half of s64 range [0, (u64)smax_value]:
- w := umin_value
- w := w if w in tnum else tnum_step(tnum, w)
- otherwise:
- w := min((u64)smin_value, umax_value)
- w := w if w in tnum else tnum_step(tnum, w)
And then check again if w still belongs to each range
(it belongs to tnum by construction).
'w' refinement for 32-bit ranges needs more thought.
It would probably be similar to 32-bit -> 64-bit from lower bound
refinement described in [1] or [2].
Wdyt?
[1] https://lore.kernel.org/bpf/20260410124035.297632-1-koike@igalia.com/
[2] https://lore.kernel.org/bpf/b2a0346a5b0818008503b721c62621918d84ad0a.1776344897.git.paul.chaignon@gmail.com/
It is much simpler with cnums [3] because sync of non-intersecting
ranges produces an empty range, and one would only need to apply the
tnum range logic from your patch-set. I really need to wrap-up that RFC.
[3] https://github.com/eddyz87/bpf/tree/cnums-everywhere
next prev parent reply other threads:[~2026-04-17 5:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8c3071d259e04aa6d0c20c7bb4e5bd31fc5335e5.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=harishankar.vishwanathan@gmail.com \
--cc=paul.chaignon@gmail.com \
--cc=santosh.nagarakatte@rutgers.edu \
--cc=shung-hsi.yu@suse.com \
--cc=srinivas.narayana@rutgers.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox