public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Paul Chaignon" <paul.chaignon@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH RFC bpf-next 1/7] bpf/verifier: Use intersection checks when simulating to detect dead branches
Date: Thu, 16 Apr 2026 18:39:56 +0000	[thread overview]
Message-ID: <20260416183957.24DEBC2BCAF@smtp.kernel.org> (raw)
In-Reply-To: <681fc6e748330e6a765a89f7193c17b33d4ea26f.1776344897.git.paul.chaignon@gmail.com>

Sashiko AI review found 1 potential issue(s):
- [Critical] Returning early from `reg_bounds_sync` on `!reg_bounds_intersect(reg)` masks verifier soundness bugs and turns them into exploitable branch-pruning vulnerabilities.
--

commit 6f55ebe5b292297be4b3fa774e1c6b87de6d0862
Author: Harishankar Vishwanathan <harishankar.vishwanathan@gmail.com>

bpf/verifier: Use intersection checks when simulating to detect dead branches

This commit introduces a new check to detect if register bounds across
domains (u64, s64, u32, s32, tnum) have an intersection. It uses this new
check to prune dead branches and to exit early during register bounds
synchronization.

> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 9e4980128151b..1d5d2b7e5140b 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c

[ ... ]

> @@ -2345,12 +2345,15 @@ static void __reg_bound_offset(struct bpf_reg_state *reg)
>  static void reg_bounds_sync(struct bpf_reg_state *reg)
>  {
> -	/* If the input reg_state is invalid, we can exit early */
> -	if (range_bounds_violation(reg))
> +	/* If the input reg_state has no intersection between abstract values, it is
> +	 * invalid. We can exit early, ensuring that subsequent operations don't
> +	 * inadvertently fix the reg_state.
> +	 */
> +	if (!reg_bounds_intersect(reg))
>  		return;

Does returning early from reg_bounds_sync() here mask verifier soundness
bugs and potentially turn them into exploitable branch-pruning regressions?

If a buggy arithmetic operation produces a register state with disjoint
domains (e.g., conflicting u32 and u64 bounds) but does not immediately
have a min > max within a single domain, reg_bounds_intersect() will
return false.

This causes reg_bounds_sync() to exit early, explicitly skipping
__update_reg_bounds() and __reg_deduce_bounds().

Before this patch, running those deduction functions on disjoint domains
would cross-constrain the bounds and naturally produce a state with
min > max (range_bounds_violation). This explicit violation would
subsequently trigger a verifier panic in reg_bounds_sanity_check(),
safely rejecting the broken program.

By skipping the deduction, the state retains its logically impossible
disjoint domains but avoids generating a range_bounds_violation. Because
reg_bounds_sanity_check() was not updated to also fail when
!reg_bounds_intersect() is true, the broken state silently passes all
verifier sanity checks.

When this disjoint register is later evaluated at a conditional jump,
simulate_both_branches_taken() will see !reg_bounds_intersect() and
conclude that the branches are dead, pruning them from verification.
This could allow out-of-bounds memory accesses in the unverified branches,
which the verifier assumes are dead but the kernel will still execute at
runtime.

Should reg_bounds_sanity_check() be updated to also fail if
!reg_bounds_intersect(reg) is true?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1776344897.git.paul.chaignon@gmail.com?part=1

  parent reply	other threads:[~2026-04-16 18:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-16 13:09 [PATCH RFC bpf-next 0/7] bpf: Fix reg_bounds' slow mode and improve verifier refinement Paul Chaignon
2026-04-16 13:11 ` [PATCH RFC bpf-next 1/7] bpf/verifier: Use intersection checks when simulating to detect dead branches Paul Chaignon
2026-04-16 14:03   ` bot+bpf-ci
2026-04-16 18:39   ` sashiko-bot [this message]
2026-04-16 13:12 ` [PATCH RFC bpf-next 2/7] selftests/bpf: Test for empty intersection of tnum and u64 Paul Chaignon
2026-04-16 14:03   ` bot+bpf-ci
2026-04-16 18:53   ` sashiko-bot
2026-04-16 13:12 ` [PATCH RFC bpf-next 3/7] selftests/bpf: Fix reg_bounds to prune on range violations Paul Chaignon
2026-04-16 19:08   ` sashiko-bot
2026-04-16 13:12 ` [PATCH RFC bpf-next 4/7] bpf: Improve 64bits bounds refinement from u32 bounds Paul Chaignon
2026-04-16 19:33   ` sashiko-bot
2026-04-16 13:12 ` [PATCH RFC bpf-next 5/7] bpf: Remove dead code from u32->*64 refinement logic Paul Chaignon
2026-04-16 13:13 ` [PATCH RFC bpf-next 6/7] selftests/bpf: Hardcode insteresting 32->64 refinement cases Paul Chaignon
2026-04-16 13:13 ` [PATCH RFC bpf-next 7/7] selftests/bpf: new cases handled by 32->64 range refinements 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=20260416183957.24DEBC2BCAF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=paul.chaignon@gmail.com \
    --cc=sashiko@lists.linux.dev \
    /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