From: sashiko-bot@kernel.org
To: "Jan-Gerd Tenberge" <janten@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf] bpf: Propagate precision for outgoing stack arguments
Date: Fri, 09 Oct 2026 07:39:07 +0000 [thread overview]
Message-ID: <sashiko-outbox-165022@kernel.org> (raw)
In-Reply-To: <20261009072752.21037-1-janten@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] bpf: mark_all_scalars_imprecise() omits stack arguments, causing state explosion
--
commit 6af07cea664bce39c3788fcfdd7a5a9e4adbc1e1
Author: Jan-Gerd Tenberge <janten@gmail.com>
Subject: bpf: Propagate precision for outgoing stack arguments
BPF subprogram arguments beyond r1-r5 are kept separately in stack_arg_regs.
This commit includes precise outgoing stack arguments in the backtracking seed
used by propagate_precision(), and marks them precise in the fallback path
as well. This prevents the verifier from missing value-dependent safety checks.
> diff --git a/kernel/bpf/states.c b/kernel/bpf/states.c
> index 18bf7b660c2f6..c62bc9fe2e325 100644
> --- a/kernel/bpf/states.c
> +++ b/kernel/bpf/states.c
> @@ -1063,6 +1063,20 @@ static int propagate_precision(struct bpf_verifier_env *env,
> bpf_bt_set_frame_slot(&env->bt, fr, i);
> first = false;
> }
> +
> + bpf_for_each_spilled_stack_arg(i, state, state_reg) {
> + if (!state_reg || state_reg->type != SCALAR_VALUE ||
> + !state_reg->precise)
> + continue;
> + if (env->log.level & BPF_LOG_LEVEL2) {
> + if (first)
> + verbose(env, "frame %d: propagating sa%d", fr, i);
> + else
> + verbose(env, ",sa%d", i);
> + }
> + bt_set_frame_stack_arg_slot(&env->bt, fr, i);
> + first = false;
> + }
> if (!first && (env->log.level & BPF_LOG_LEVEL2))
> verbose(env, "\n");
> }
[Severity: Medium]
Does this patch also need to update mark_all_scalars_imprecise() in this
same file?
When a state is added to the explored states cache, mark_all_scalars_imprecise()
clears precision marks to ensure maximum pruning efficiency. It currently
iterates over standard registers and stack slots, but misses stack_arg_regs:
kernel/bpf/states.c:mark_all_scalars_imprecise() {
...
for (j = 0; j < bpf_stack_nr_slots(func); j++) {
struct bpf_stack_state *ss = bpf_stack_slot(func, j);
if (!bpf_is_spilled_reg(ss))
continue;
reg = &ss->spilled_ptr;
if (reg->type != SCALAR_VALUE)
continue;
reg->precise = false;
}
...
}
Because this patch allows stack arguments to be marked precise, wouldn't any
precise stack argument enter the cache with precise = true?
When a later verification path compares against this cached state via
regsafe(), the old stack argument having precise = true would enforce tight
bounds checks or an exact memory match.
Could this cause state explosion by preventing pruning for any state with
different scalar values?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261009072752.21037-1-janten@gmail.com?part=1
prev parent reply other threads:[~2026-10-09 7:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 7:27 [PATCH bpf] bpf: Propagate precision for outgoing stack arguments Jan-Gerd Tenberge
2026-10-09 7:39 ` sashiko-bot [this message]
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=sashiko-outbox-165022@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=janten@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox