From: sashiko-bot@kernel.org
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v5 09/14] bpf: Report Memory Safety bounds errors
Date: Sat, 15 Aug 2026 06:59:55 +0000 [thread overview]
Message-ID: <20260815065956.49D2B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260815064612.378577-10-memxor@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] bpf_diag_stack_read_uninit incorrectly diagnoses reads of special stack slots (e.g., STACK_DYNPTR) as uninitialized memory.
- [Medium] bpf_diag_memory incorrectly attributes variable stack access failures from atomic instructions to a 'helper function'.
--
--- Patch [9]: [PATCH bpf-next v5 09/14] bpf: Report Memory Safety bounds errors ---
commit 787129fefde67f039a1ddb3b85e61af60e79f8f2
Author: Kumar Kartikeya Dwivedi <memxor@gmail.com>
bpf: Report Memory Safety bounds errors
Augment selected memory-range verifier failures with Memory Safety reports
while preserving the existing terse verifier messages for compatibility.
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -3851,6 +3875,8 @@ static int check_stack_read_fixed_off(struct bpf_verifier_env *env,
> } else {
> verbose(env, "invalid read from stack off %d+%d size %d\n",
> off, i, size);
> + bpf_diag_stack_read_uninit(env, off, i,
> + size);
> }
> return -EACCES;
> }
[Severity: Medium]
Will this else branch also catch special stack slots like STACK_DYNPTR or
STACK_ITER?
If a BPF program directly reads a special stack slot, the verifier rejects
it because it contains opaque internal state. Does calling
bpf_diag_stack_read_uninit() here incorrectly diagnose these special slots
as uninitialized memory? This might lead users to incorrectly try using
CAP_PERFMON or initializing the memory, which would corrupt the underlying
object.
[ ... ]
> @@ -3909,6 +3935,7 @@ static int check_stack_read_fixed_off(struct bpf_verifier_env *env,
> } else {
> verbose(env, "invalid read from stack off %d+%d size %d\n",
> off, i, size);
> + bpf_diag_stack_read_uninit(env, off, i, size);
> }
> return -EACCES;
> }
[Severity: Medium]
Similar to the above, does this second else branch for non-spilled slots
also misdiagnose special slot reads as uninitialized memory?
[ ... ]
> @@ -4001,11 +4028,19 @@ static int check_stack_read(struct bpf_verifier_env *env,
> * check_stack_read_fixed_off).
> */
> if (dst_regno < 0 && var_off) {
> + const char *reason;
> char tn_buf[48];
>
> tnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);
> verbose(env, "variable offset stack pointer cannot be passed into helper function; var_off=%s off=%d size=%d\n",
> tn_buf, off, size);
> + reason = bpf_diag_fmt(env,
> + "The helper would access the stack through variable offset %s plus fixed offset %d and size %d. "
> + "Helper stack memory arguments require a constant stack offset and a precise initialized range.",
> + tn_buf, off, size);
> + bpf_diag_memory(
> + env, env->insn_idx, "variable stack access", reason,
> + "Use a fixed stack offset for helper memory arguments, or copy the needed bytes into a fixed stack slot first.");
> return -EACCES;
> }
[Severity: Medium]
Are we sure this condition is triggered by helper functions?
In check_stack_read(), a destination register less than 0 is triggered
exclusively by atomic instructions, not by helper functions which
instead use check_helper_mem_access().
Could this new diagnostic text falsely attribute atomic instruction failures
to helper functions and incorrectly suggest changes for helper memory
arguments?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260815064612.378577-1-memxor@gmail.com?part=9
next prev parent reply other threads:[~2026-08-15 6:59 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-15 6:45 [PATCH bpf-next v5 00/14] Redesign Verification Errors Kumar Kartikeya Dwivedi
2026-08-15 6:45 ` [PATCH bpf-next v5 01/14] bpf: Add verifier diagnostics report helpers Kumar Kartikeya Dwivedi
2026-08-15 6:52 ` sashiko-bot
2026-08-15 7:20 ` bot+bpf-ci
2026-08-15 6:45 ` [PATCH bpf-next v5 02/14] bpf: Add source and instruction diagnostic context Kumar Kartikeya Dwivedi
2026-08-15 7:01 ` sashiko-bot
2026-08-15 7:34 ` bot+bpf-ci
2026-08-15 6:45 ` [PATCH bpf-next v5 03/14] bpf: Add verifier diagnostic event log Kumar Kartikeya Dwivedi
2026-08-15 7:34 ` bot+bpf-ci
2026-08-15 6:45 ` [PATCH bpf-next v5 04/14] bpf: Prune verifier diagnostics when switching paths Kumar Kartikeya Dwivedi
2026-08-15 6:46 ` [PATCH bpf-next v5 05/14] bpf: Track verifier register diagnostic events Kumar Kartikeya Dwivedi
2026-08-15 7:34 ` bot+bpf-ci
2026-08-15 7:38 ` sashiko-bot
2026-08-15 6:46 ` [PATCH bpf-next v5 06/14] bpf: Track verifier reference " Kumar Kartikeya Dwivedi
2026-08-15 6:46 ` [PATCH bpf-next v5 07/14] bpf: Track verifier context " Kumar Kartikeya Dwivedi
2026-08-15 7:20 ` bot+bpf-ci
2026-08-15 6:46 ` [PATCH bpf-next v5 08/14] bpf: Report Register Type Safety errors Kumar Kartikeya Dwivedi
2026-08-15 7:34 ` bot+bpf-ci
2026-08-15 6:46 ` [PATCH bpf-next v5 09/14] bpf: Report Memory Safety bounds errors Kumar Kartikeya Dwivedi
2026-08-15 6:59 ` sashiko-bot [this message]
2026-08-15 7:34 ` bot+bpf-ci
2026-08-15 6:46 ` [PATCH bpf-next v5 10/14] bpf: Report Resource Lifetime reference leaks Kumar Kartikeya Dwivedi
2026-08-15 7:34 ` bot+bpf-ci
2026-08-15 6:46 ` [PATCH bpf-next v5 11/14] bpf: Report Call Type Safety argument errors Kumar Kartikeya Dwivedi
2026-08-15 7:49 ` bot+bpf-ci
2026-08-15 6:46 ` [PATCH bpf-next v5 12/14] bpf: Report Execution Context Safety errors Kumar Kartikeya Dwivedi
2026-08-15 7:34 ` bot+bpf-ci
2026-08-15 6:46 ` [PATCH bpf-next v5 13/14] bpf: Report Program Structure CFG errors Kumar Kartikeya Dwivedi
2026-08-15 7:34 ` bot+bpf-ci
2026-08-15 6:46 ` [PATCH bpf-next v5 14/14] bpf: Report Policy helper and kfunc errors Kumar Kartikeya Dwivedi
2026-08-15 7:20 ` bot+bpf-ci
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=20260815065956.49D2B1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=memxor@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