From: sashiko-bot@kernel.org
To: "Eduard Zingerman" <eddyz87@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 05/13] bpf: 4-byte precise clean_verifier_state
Date: Fri, 14 Aug 2026 00:48:24 +0000 [thread overview]
Message-ID: <20260814004829.D012E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260410-patch-set-v3-5-1f5826dc0ef2@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Verifier bypass leading to out-of-bounds memory access due to precision loss when 8-byte scalar spills are partially read.
--
--- Patch [5]: [PATCH bpf-next v3 05/13] bpf: 4-byte precise clean_verifier_state ---
commit 720b66feb217d6b05897c14d4beceb7ff588cf92
Author: Eduard Zingerman <eddyz87@gmail.com>
bpf: 4-byte precise clean_verifier_state
Migrate clean_verifier_state() and its liveness queries from 8-byte
SPI granularity to 4-byte half-slot granularity.
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index ee3945a919e3a..0731e99aa5412 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
[ ... ]
> @@ -20075,26 +20074,83 @@ static void clean_func_state(struct bpf_verifier_env *env,
[ ... ]
> + /*
> + * Only destroy spilled_ptr when hi half is dead.
> + * If hi half is still live with STACK_SPILL, the
> + * spilled_ptr metadata is needed for correct state
> + * comparison in stacksafe().
> + * is_spilled_reg() is using slot_type[7], but
> + * is_spilled_scalar_after() check either slot_type[0] or [4]
> + */
> + if (!hi_live) {
> + struct bpf_reg_state *spill = &st->stack[i].spilled_ptr;
> +
> + if (lo_live && stype == STACK_SPILL) {
> + u8 val = STACK_MISC;
> +
> + /*
> + * 8 byte spill of scalar 0 where half slot is dead
> + * should become STACK_ZERO in lo 4 bytes.
> + */
> + if (register_is_null(spill))
> + val = STACK_ZERO;
> + for (j = 0; j < 4; j++) {
> + u8 *t = &st->stack[i].slot_type[j];
> +
> + if (*t == STACK_SPILL)
> + *t = val;
> + }
> + }
> + __mark_reg_not_init(env, spill);
> + }
[Severity: Critical]
Can this lead to a verifier bypass and out-of-bounds access due to precision
loss when 8-byte scalar spills are partially read?
If a code path spills a non-zero precise scalar (e.g., an array index) to the
stack as an 8-byte write, and then reads only the upper 4 bytes, `lo_live`
would be true and `hi_live` would be false.
This code then destroys the `spilled_ptr` via `__mark_reg_not_init()`, which
loses the exact value and precision metadata. It downgrades the live half to
`STACK_MISC`, which represents an unbounded scalar.
If a different path reaches the same point with an out-of-bounds precise
scalar, wouldn't `stacksafe()` compare the new state against the cached state
containing `STACK_MISC`?
Since an imprecise unbounded scalar is evaluated as a superset of any precise
scalar in `regsafe()`, wouldn't the out-of-bounds path be incorrectly pruned,
allowing an out-of-bounds memory access to execute at runtime?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260410-patch-set-v3-0-1f5826dc0ef2@gmail.com?part=5
next prev parent reply other threads:[~2026-08-14 0:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-10 9:29 [PATCH bpf-next v3 00/13] bpf: static stack liveness data flow analysis Eduard Zingerman
2026-04-10 9:29 ` [PATCH bpf-next v3 01/13] bpf: share several utility functions as internal API Eduard Zingerman
2026-04-10 9:29 ` [PATCH bpf-next v3 02/13] bpf: save subprogram name in bpf_subprog_info Eduard Zingerman
2026-04-10 9:29 ` [PATCH bpf-next v3 03/13] bpf: Add spis_*() helpers for 4-byte stack slot bitmasks Eduard Zingerman
2026-04-10 9:29 ` [PATCH bpf-next v3 04/13] bpf: make liveness.c track stack with 4-byte granularity Eduard Zingerman
2026-04-10 9:29 ` [PATCH bpf-next v3 05/13] bpf: 4-byte precise clean_verifier_state Eduard Zingerman
2026-08-14 0:48 ` sashiko-bot [this message]
2026-04-10 9:29 ` [PATCH bpf-next v3 06/13] bpf: prepare bpf_liveness api for use by static analysis pass Eduard Zingerman
2026-04-10 9:57 ` bot+bpf-ci
2026-04-10 9:29 ` [PATCH bpf-next v3 07/13] bpf: introduce forward arg-tracking dataflow analysis Eduard Zingerman
2026-04-10 10:10 ` bot+bpf-ci
2026-04-10 9:29 ` [PATCH bpf-next v3 08/13] bpf: simplify liveness to use (callsite, depth) keyed func_instances Eduard Zingerman
2026-04-10 9:29 ` [PATCH bpf-next v3 09/13] bpf: change logging scheme for live stack analysis Eduard Zingerman
2026-04-10 9:57 ` bot+bpf-ci
2026-04-10 17:12 ` Eduard Zingerman
2026-04-10 9:29 ` [PATCH bpf-next v3 10/13] selftests/bpf: update existing tests due to liveness changes Eduard Zingerman
2026-04-10 9:29 ` [PATCH bpf-next v3 11/13] selftests/bpf: adjust verifier_log buffers Eduard Zingerman
2026-04-10 9:29 ` [PATCH bpf-next v3 12/13] selftests/bpf: add new tests for static stack liveness analysis Eduard Zingerman
2026-04-10 9:29 ` [PATCH bpf-next v3 13/13] bpf: poison dead stack slots Eduard Zingerman
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=20260814004829.D012E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=eddyz87@gmail.com \
--cc=sashiko-reviews@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.