From: Paul Chaignon <paul.chaignon@gmail.com>
To: bpf@vger.kernel.org
Cc: Harishankar Vishwanathan <harishankar.vishwanathan@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Shung-Hsi Yu <shung-hsi.yu@suse.com>,
Srinivas Narayana <srinivas.narayana@rutgers.edu>,
Santosh Nagarakatte <santosh.nagarakatte@rutgers.edu>
Subject: [PATCH bpf-next v3 0/6] Fix invariant violations and improve branch detection
Date: Thu, 2 Apr 2026 17:07:25 +0200 [thread overview]
Message-ID: <cover.1775142354.git.paul.chaignon@gmail.com> (raw)
This patchset fixes invariant violations on register bounds. These
invariant violations cause a warning and happen when reg_bounds_sync is
trying to refine register bounds while walking an impossible branch.
This patchset takes this situation as an opportunity to improve
verification performance. That is, the verifier will use the invariant
violations as a signal that a branch cannot be taken and process it as
dead code.
This patchset implements this approach and covers it in selftests with
a new invariant violation case. Some of the logic in reg_bounds_sync
likely acts as a duplicate with logic from is_scalar_branch_taken. This
patchset does not attempt to remove superfluous logic from
is_scalar_branch_taken and leaves it to a future patchset (ex. once
syzbot has confirmed that all invariant violations are fixed).
In the future, there is also a potential opportunity to simplify
existing logic by merging reg_bounds_sync and range_bounds_violation
(have reg_bounds_sync error out on invariant violation). That is
however not needed to fix invariant violation, which we focus on in
this patchset.
Changes in v3:
- Rename and refactor the helper functions checking for tnum-related
invariant violations (Mykyta).
- Small changes to comment style in verifier changes and new selftest
(Mykyta).
- Rebased.
Changes in v2:
- Moved tmp registers to env in preparatory commit (Eduard).
- Updated reg_bounds_sync to bail out in case of ill-formed
registers, thus avoiding one set of invariant violation checks in
simulate_both_branches_taken (Eduard).
- Drop the Fixes tag to avoid misleading backporters (Shung-Hsi).
- Improve wording of commit descriptions (Shung-Hsi, Hari).
- Fix error in code comments (AI bot).
- Rebased.
Harishankar Vishwanathan (3):
bpf: Refactor reg_bounds_sanity_check
bpf: Exit early if reg_bounds_sync gets invalid inputs
bpf: Simulate branches to prune based on range violations
Paul Chaignon (3):
bpf: Use bpf_verifier_env buffers for reg_set_min_max
selftests/bpf: Cover invariant violation case from syzbot
selftests/bpf: Remove invariant violation flags
include/linux/bpf_verifier.h | 4 +-
kernel/bpf/verifier.c | 201 ++++++++++--------
.../selftests/bpf/progs/verifier_bounds.c | 51 +++--
3 files changed, 148 insertions(+), 108 deletions(-)
--
2.43.0
next reply other threads:[~2026-04-02 15:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 15:07 Paul Chaignon [this message]
2026-04-02 15:08 ` [PATCH bpf-next v3 1/6] bpf: Refactor reg_bounds_sanity_check Paul Chaignon
2026-04-03 0:53 ` Eduard Zingerman
2026-04-02 15:09 ` [PATCH bpf-next v3 2/6] bpf: Use bpf_verifier_env buffers for reg_set_min_max Paul Chaignon
2026-04-02 15:10 ` [PATCH bpf-next v3 3/6] bpf: Exit early if reg_bounds_sync gets invalid inputs Paul Chaignon
2026-04-03 0:54 ` Eduard Zingerman
2026-04-02 15:10 ` [PATCH bpf-next v3 4/6] bpf: Simulate branches to prune based on range violations Paul Chaignon
2026-04-02 16:28 ` bot+bpf-ci
2026-04-02 16:33 ` Paul Chaignon
2026-04-03 1:05 ` Eduard Zingerman
2026-04-02 15:11 ` [PATCH bpf-next v3 5/6] selftests/bpf: Cover invariant violation case from syzbot Paul Chaignon
2026-04-02 15:12 ` [PATCH bpf-next v3 6/6] selftests/bpf: Remove invariant violation flags Paul Chaignon
2026-04-03 1:08 ` [PATCH bpf-next v3 0/6] Fix invariant violations and improve branch detection Eduard Zingerman
2026-04-03 1:30 ` patchwork-bot+netdevbpf
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=cover.1775142354.git.paul.chaignon@gmail.com \
--to=paul.chaignon@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=harishankar.vishwanathan@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