mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Vineet Gupta <vineet.gupta@linux.dev>,
	Yiyang Chen	 <chenyy23@mails.tsinghua.edu.cn>,
	Alexei Starovoitov <ast@kernel.org>,
	 Daniel Borkmann <daniel@iogearbox.net>,
	John Fastabend <john.fastabend@gmail.com>,
	Andrii Nakryiko	 <andrii@kernel.org>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	 Jiri Olsa <jolsa@kernel.org>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	Ihor Solodrai	 <ihor.solodrai@linux.dev>,
	Shuah Khan <shuah@kernel.org>
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-kselftest@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 2/2] selftests/bpf: Cover mixed arena and stack atomics
Date: Tue, 18 Aug 2026 12:56:23 -0700	[thread overview]
Message-ID: <ba901e5268dc739711b9a5e1d9405be6953e35f1.camel@gmail.com> (raw)
In-Reply-To: <ac19d435-4c92-42c8-9db1-2db1ab854c3c@linux.dev>

On Tue, 2026-08-18 at 12:35 -0700, Vineet Gupta wrote:
> On 8/16/26 4:36 PM, Eduard Zingerman wrote:
> > On Sun, 2026-08-16 at 16:17 -0700, Eduard Zingerman wrote:
> > > On Sun, 2026-08-16 at 10:56 +0000, Yiyang Chen wrote:
> > > > Add a verifier test with one atomic RMW instruction reached through
> > > > PTR_TO_ARENA and PTR_TO_STACK paths. The verifier must reject the
> > > > shared instruction with the existing incompatible-pointer diagnostic.
> > > > 
> > > > Signed-off-by: Yiyang Chen <chenyy23@mails.tsinghua.edu.cn>
> > > > ---
> > > >   tools/testing/selftests/bpf/progs/verifier_arena.c | 39 ++++++++++++++++++++++
> > > >   1 file changed, 39 insertions(+)
> > > > 
> > > > diff --git a/tools/testing/selftests/bpf/progs/verifier_arena.c b/tools/testing/selftests/bpf/progs/verifier_arena.c
> > > > index b241bbcf54a8a..b22bab33301ab 100644
> > > > --- a/tools/testing/selftests/bpf/progs/verifier_arena.c
> > > > +++ b/tools/testing/selftests/bpf/progs/verifier_arena.c
> > > > @@ -637,6 +637,45 @@ int non_arena_ptr_add_to_arena_ptr(void *ctx)
> > > >   
> > > >   #endif
> > > >   
> > > > +static const struct bpf_insn addr_space_cast_insn = {
> > > > +	.code = 0xbf,
> > > > +	.dst_reg = BPF_REG_7,
> > > > +	.src_reg = BPF_REG_7,
> > > > +	.off = 1,
> > > > +	.imm = 1,
> > > > +};
> > > > +
> > > > +SEC("socket")
> > > > +__description("arena and stack atomic at the same instruction")
> > > > +__failure __msg("same insn cannot be used with different pointers")
> > > > +__arch_x86_64
> > > > +__load_if_JITed()
> > > > +__naked void mixed_arena_stack_atomic(void)
> > > > +{
> > > > +	asm volatile ("					\
> > > > +	r1 = %[arena] ll;				\
> > > > +	r6 = r10;					\
> > > > +	r6 += -8;					\
> > > > +	r9 = 0;					\
> > > > +	*(u64 *)(r6 + 0) = r9;			\
> > > > +	r7 = 8192;					\
> > > > +	.8byte %[addr_space_cast];			\
> > > I'm going to fix this to:
> > > 
> > > 	r7 = addr_space_cast(r7, 0, 1);			\
> > > 
> > > as in the test case above.
> > > Waiting for CI [1].
> > > 
> > > [1] https://github.com/kernel-patches/bpf/pull/13325
> > 
> > A...and it requires another exception for GCC-BPF:
> > https://github.com/kernel-patches/bpf/blob/bpf-next_base/ci/vmtest/configs/DENYLIST.test_progs-bpf_gcc
> > 
> > Ihor, it's a third time GCC-BPF strikes this weekend.
> > What do people think about downgrading it to may-fail until the
> > DENYLIST decreases to something reasonable?
> 
> While bpf-gcc is improving, slowly, we can in parallel do alittle better 
> on test hygiene as well. In this case by correctly bracketing the tests 
> with _BPF_FEATURE_XXX.

Yes, that's what I ended up doing. Should have paid attention to the
#if .. #endif bracket used by the textually preceding test.
Sorry for lashing out.

> Co-incidently I have a series in works from an accidental discovery of 
> llvm-only testing coverage (rely solely on __clang_version macro) which 
> I'll follow up on the list shortly.
> 
> Thx,
> -Vineet
> 
> 
> > 
> > Anyway, I'll wrap-up with this patch-set in the evening.
> > 
> > > > +	call %[bpf_get_prandom_u32];			\
> > > > +	if w0 != 0 goto 1f;				\
> > > > +	r8 = r6;					\
> > > > +	goto 2f;					\
> > > > +1:	r8 = r7;					\
> > > > +2:	r9 = 1;					\
> > > > +	lock *(u64 *)(r8 + 0) += r9;			\
> > > > +	r0 = 0;					\
> > > > +	exit;						\
> > > > +"	:
> > > > +	: __imm_addr(arena),
> > > > +	  __imm_insn(addr_space_cast, addr_space_cast_insn),
> > > > +	  __imm(bpf_get_prandom_u32)
> > > > +	: __clobber_all);
> > > > +}
> > > > +
> > > >   static __noinline
> > > >   u32 __arena *check_arena_arg_nonglobal(u32 __arena *arg)
> > > >   {

  reply	other threads:[~2026-08-18 19:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-16 10:56 [PATCH bpf-next v2 0/2] bpf: Reject mixed arena and ordinary atomic paths Yiyang Chen
2026-08-16 10:56 ` [PATCH bpf-next v2 1/2] bpf: Check pointer type for all atomic RMW paths Yiyang Chen
2026-08-16 10:56 ` [PATCH bpf-next v2 2/2] selftests/bpf: Cover mixed arena and stack atomics Yiyang Chen
2026-08-16 11:43   ` bot+bpf-ci
2026-08-16 23:17   ` Eduard Zingerman
2026-08-16 23:36     ` Eduard Zingerman
2026-08-16 23:56       ` Eduard Zingerman
2026-08-18 19:35       ` Vineet Gupta
2026-08-18 19:56         ` Eduard Zingerman [this message]
2026-08-18 21:03           ` Vineet Gupta
2026-08-18 20:06       ` Ihor Solodrai
2026-08-17  6:10 ` [PATCH bpf-next v2 0/2] bpf: Reject mixed arena and ordinary atomic paths patchwork-bot+netdevbpf

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=ba901e5268dc739711b9a5e1d9405be6953e35f1.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chenyy23@mails.tsinghua.edu.cn \
    --cc=daniel@iogearbox.net \
    --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@linux.dev \
    --cc=memxor@gmail.com \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=vineet.gupta@linux.dev \
    --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®