mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vineet Gupta <vineet.gupta@linux.dev>
To: bot+bpf-ci@kernel.org, ast@kernel.org, daniel@iogearbox.net,
	andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com
Cc: martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev,
	jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev,
	john.fastabend@gmail.com, shuah@kernel.org, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	martin.lau@kernel.org, mason@kernel.org
Subject: Re: [PATCH bpf-next v3 10/12] selftests/bpf: Cover the low-32 link for narrowing stack fills
Date: Mon, 26 Oct 2026 13:21:02 -0700	[thread overview]
Message-ID: <2b712ff8-21cf-4371-9663-2395ceed351e@linux.dev> (raw)
In-Reply-To: <fb6e1da8e20593510ea7dbfc1527db1aaf4682c22968a209dbf2ed771646a6fd@mail.kernel.org>

On 10/20/26 9:52 AM, bot+bpf-ci@kernel.org wrote:
>> selftests/bpf: Cover the low-32 link for narrowing stack fills
> TL;DR: Test issue: sext_fill_does_not_inherit_zext_link appears never to put a
> zero-extending link on the stack slot, so it can't distinguish the new
> check_mem_access() condition from the old one; its comment and commit message
> look inaccurate.
>
>> diff --git a/tools/testing/selftests/bpf/progs/verifier_linked_scalars.c b/tools/testing/selftests/bpf/progs/verifier_linked_scalars.c
>> index 69efe1381eca..ab78285153fb 100644
>> --- a/tools/testing/selftests/bpf/progs/verifier_linked_scalars.c
>> +++ b/tools/testing/selftests/bpf/progs/verifier_linked_scalars.c
>> +/*
>> + * A sign-extending fill must not come away with a zero-extending link. The
>> + * slot below already fits 32 bits, so the fill is not narrowing and assigns
>> + * no link kind of its own, and "state->regs[dst] = *reg" copies the slot's
>> + * verbatim; check_mem_access() is what has to drop it, since it would leave
>> + * r2 recording a zero-extension of a value it has just sign-extended.
>> + * Asserted on the register dump rather than on a guarded branch, so it pins
>> + * the rule itself and not a downstream effect.
>> + */
>> +SEC("socket")
>> +__success __log_level(2)
>> +/* a copied link would print as R2=scalar(id=N+0,smin=... */
>> +__msg("(81) r2 = *(s32 *)(r10 {{.*}} R2=scalar(smin=")
>> +__naked void sext_fill_does_not_inherit_zext_link(void)
>> +{
>> +	asm volatile ("						\
>> +	call %[bpf_get_prandom_u32];				\
>> +	r6 = r0;						\
>> +	call %[bpf_get_prandom_u32];				\
>> +	r0 <<= 32;						\
>> +	r6 |= r0;		/* r6 = full 64-bit unknown */	\
>> +	w7 = w6;		/* r7 = zext32(r6), fits 32 bits */ \
>> +	*(u64 *)(r10 - 8) = r7;					\
> Does this test ever put a zero-extending link on the slot?

Sorry, it doesn't and nothing in this patch can, so it is dropped in v4.


> The w7 = w6 above does give r7 BPF_REG_LINK_ZEXT, but the spill that follows
> clears it.  In check_stack_write_fixed_off(), r7 fits in 32 bits, so
> assign_scalar_id_before_mov() runs before save_register_state():
>
>      if (src_reg->link_kind && src_reg->link_kind != BPF_REG_LINK_SEXT)
>          bpf_clear_scalar_id(src_reg);
>      ...
>      if (!src_reg->id && !tnum_is_const(src_reg->var_off))
>          src_reg->id = ++env->id_gen;
>
> The slot ends up with a fresh id and link_kind == BPF_REG_LINK_NONE.  The
> 4-byte ldsx is not narrowing, so the fill copies a plain id, and
> check_mem_access() drops it through the existing !no_sext clear.  The
> link_kind == BPF_REG_LINK_SEXT part of the new condition never sees a ZEXT
> kind here.
>
> This leaves two problems.
>
> First, the in-test comment looks wrong:
>
>      /* a copied link would print as R2=scalar(id=N+0,smin=... */
>
> print_reg_state() prints +delta only when link_kind is set, so a surviving
> plain id would print as R2=scalar(id=N,smin=...
>
> Second, the commit message says "The last two pin the link-kind checks in
> check_mem_access()", but this test cannot tell the new check from the old
> one.  It passes with the pre-series:

Agreed. Pre-series the fill gets a plain id from 
assign_scalar_id_before_mov() and check_mem_access() drops it through 
the existing !no_sext clear, so R2 prints without an id either way and 
the assertion cannot separate them.
The changelog said "the last two"; it is now "the last one", counting 
only sext_byte_fill_drops_sext_link.


> That holds even after 3649346488fc ("bpf: Track low-32 scalar equality across
> narrowing stack spills"), because the fill-side
> assign_scalar_id_before_mov(reg) clears the slot's new ZEXT kind before the
> copy.  No later commit in the range (3649346488fc, 73fbac05c8bd) changes this
> test.

Right.

> Should the comment, the test name and the commit message describe what is
> actually pinned here (a plain id dropped across a range-changing 4-byte
> ldsx)?  Or should the test be reworked once a ZEXT-carrying slot is
> reachable?

Neither: the test is dropped in v4.

Re-describing seems viable but is conceptually wrong. It pins a plain id 
dropped across a range-changing ldsx which is pre-existing behavior that 
this series does not touch, so doesn't make sense to introduce here. 
Reworking after "a ZEXT-carrying slot is reachable" might be better 
suited, but that is 11/12 and 12/12, which are tagged [do not merge]. 
12/12's version has the same defect and is dropped too, so both go.

Thx,
-Vineet

> ---
> 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/39458500836


  reply	other threads:[~2026-10-26 20:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 16:18 [PATCH bpf-next v3 00/12] bpf: track scalar equality across the low 32 bits Vineet Gupta
2026-10-20 16:18 ` [PATCH bpf-next v3 01/12] bpf: Keep the 32-bit range across a sign extension that cannot change it Vineet Gupta
2026-10-20 16:18 ` [PATCH bpf-next v3 02/12] selftests/bpf: Cover sign extensions that cannot change the range Vineet Gupta
2026-10-20 16:18 ` [PATCH bpf-next v3 03/12] bpf: Prepare linked scalars for relations narrower than 64 bits Vineet Gupta
2026-10-20 17:08   ` bot+bpf-ci
2026-10-26 22:52     ` Vineet Gupta
2026-10-20 16:18 ` [PATCH bpf-next v3 04/12] bpf: Track low-32 scalar equality across zero-extending movs Vineet Gupta
2026-10-20 17:09   ` bot+bpf-ci
2026-10-26 20:30     ` Vineet Gupta
2026-10-20 16:19 ` [PATCH bpf-next v3 05/12] selftests/bpf: Cover the low-32 link for " Vineet Gupta
2026-10-20 16:53   ` bot+bpf-ci
2026-10-26 18:36     ` Vineet Gupta
2026-10-20 16:19 ` [PATCH bpf-next v3 06/12] bpf: Track low-32 scalar equality across sign-extending movs Vineet Gupta
2026-10-20 16:19 ` [PATCH bpf-next v3 07/12] selftests/bpf: Cover the low-32 link for " Vineet Gupta
2026-10-20 16:19 ` [PATCH bpf-next v3 08/12] bpf: Recover the low 32 bits on the reverse link direction Vineet Gupta
2026-10-20 16:53   ` bot+bpf-ci
2026-10-26 19:57     ` Vineet Gupta
2026-10-20 16:19 ` [PATCH bpf-next v3 09/12] bpf: Track low-32 scalar equality across narrowing stack fills Vineet Gupta
2026-10-20 16:19 ` [PATCH bpf-next v3 10/12] selftests/bpf: Cover the low-32 link for " Vineet Gupta
2026-10-20 16:52   ` bot+bpf-ci
2026-10-26 20:21     ` Vineet Gupta [this message]
2026-10-20 16:19 ` [PATCH bpf-next v3 11/12] [do not merge] bpf: Track low-32 scalar equality across narrowing stack spills Vineet Gupta
2026-10-20 16:19 ` [PATCH bpf-next v3 12/12] [do not merge] selftests/bpf: Cover the low-32 link for " Vineet Gupta

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=2b712ff8-21cf-4371-9663-2395ceed351e@linux.dev \
    --to=vineet.gupta@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bot+bpf-ci@kernel.org \
    --cc=bpf@vger.kernel.org \
    --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=mason@kernel.org \
    --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®