From: bot+bpf-ci@kernel.org
To: chenyy23@mails.tsinghua.edu.cn,ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,eddyz87@gmail.com,memxor@gmail.com
Cc: chenyy23@mails.tsinghua.edu.cn,john.fastabend@gmail.com,martin.lau@linux.dev,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,emil@etsalapatis.com,shuah@kernel.org,bpf@vger.kernel.org,linux-kselftest@vger.kernel.org,linux-kernel@vger.kernel.org,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,clm@meta.com,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next 2/2] selftests/bpf: Cover helper reads of invalid spill siblings
Date: Mon, 13 Jul 2026 07:17:35 +0000 (UTC) [thread overview]
Message-ID: <2cc3bdacec86e02e36a627faa455d53fabfd5333403eb629ad812717288d67d6@mail.kernel.org> (raw)
In-Reply-To: <feb30511a4b3e198253666b5ea2499d0944c153f.1783920884.git.chenyy23@mails.tsinghua.edu.cn>
[-- Attachment #1: Type: text/plain, Size: 2689 bytes --]
> selftests/bpf: Cover helper reads of invalid spill siblings
>
> Add a verifier_spill_fill case that passes an untouched byte next to a
> one-byte scalar spill to bpf_map_update_elem(). The full-capability load
> retains the existing uninitialized-stack behavior, while the CAP_BPF-only
> load must reject the STACK_INVALID helper read.
>
> Signed-off-by: Yiyang Chen <chenyy23@mails.tsinghua.edu.cn>
This test covers a verifier bug where a helper read accepted an
uninitialized (STACK_INVALID) sibling byte next to a narrow (<8-byte) scalar
spill. That behavior came in when sub-8-byte scalar spill/refill support was
added, which left sibling bytes STACK_INVALID while the slot still reported a
spilled scalar.
Should this carry the same Fixes: tag as the companion verifier fix so stable
backports pull the test in alongside it?
Fixes: 354e8f1970f8 ("bpf: Support <8-byte scalar spill and refill")
> diff --git a/tools/testing/selftests/bpf/progs/verifier_spill_fill.c b/tools/testing/selftests/bpf/progs/verifier_spill_fill.c
> index 8b166c42c4e0e..e686f6d8d5656 100644
> --- a/tools/testing/selftests/bpf/progs/verifier_spill_fill.c
> +++ b/tools/testing/selftests/bpf/progs/verifier_spill_fill.c
[ ... ]
> @@ -1307,6 +1314,32 @@ __naked void stack_noperfmon_spill_32bit_onto_64bit_slot(void)
> : __clobber_all);
> }
>
> +SEC("socket")
> +__description("helper read must reject an invalid sibling of a narrow spill")
> +__success
> +__caps_unpriv(CAP_BPF)
> +__failure_unpriv __msg_unpriv("invalid read from stack R3 off -7+0 size 1")
> +__naked void helper_read_invalid_partial_spill_sibling(void)
> +{
> + asm volatile ("r5 = 1;\n\t"
> + "*(u8 *)(r10 - 8) = r5;\n\t"
> + "r2 = 0;\n\t"
> + "*(u32 *)(r10 - 16) = r2;\n\t"
this isn't a bug, but could this asm block use the same backslash
line-continuation style as the neighbouring tests in this file? The two
tests just above it, stack_noperfmon_reject_invalid_read() and
stack_noperfmon_spill_32bit_onto_64bit_slot(), write a single string with
trailing tab-backslash, and this is the only "\n\t" per-line block in
verifier_spill_fill.c.
> + "r1 = %[map_partial_spill] ll;\n\t"
> + "r2 = r10;\n\t"
> + "r2 += -16;\n\t"
> + "r3 = r10;\n\t"
> + "r3 += -7;\n\t"
> + "r4 = 0;\n\t"
> + "call %[bpf_map_update_elem];\n\t"
> + "r0 = 0;\n\t"
> + "exit;\n\t"
> + :
> + : __imm(bpf_map_update_elem),
> + __imm_addr(map_partial_spill)
> + : __clobber_all);
> +}
>
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/29229349078
prev parent reply other threads:[~2026-07-13 7:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 6:16 [PATCH bpf-next 0/2] bpf: Validate byte type for helper stack reads Yiyang Chen
2026-07-13 6:16 ` [PATCH bpf-next 1/2] bpf: Check byte type when validating " Yiyang Chen
2026-07-13 21:22 ` Eduard Zingerman
2026-07-14 18:05 ` Yiyang Chen
2026-07-13 6:16 ` [PATCH bpf-next 2/2] selftests/bpf: Cover helper reads of invalid spill siblings Yiyang Chen
2026-07-13 7:17 ` bot+bpf-ci [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=2cc3bdacec86e02e36a627faa455d53fabfd5333403eb629ad812717288d67d6@mail.kernel.org \
--to=bot+bpf-ci@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chenyy23@mails.tsinghua.edu.cn \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@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
all inboxes | Powered by JetHome®