mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Nuoqi Gui" <gnq25@mails.tsinghua.edu.cn>
To: "Emil Tsalapatis" <emil@etsalapatis.com>
Cc: "Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Luis Gerhorst" <luis.gerhorst@fau.de>,
	"Shuah Khan" <shuah@kernel.org>,
	bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: Re: [PATCH bpf 2/2] selftests/bpf: Cover stack nospec slot indexing
Date: Wed, 17 Jun 2026 22:01:24 +0800 (GMT+08:00)	[thread overview]
Message-ID: <592abb4b.7e4ff.19ed5e2ff61.Coremail.gnq25@mails.tsinghua.edu.cn> (raw)
In-Reply-To: <DJAS8Y6NFDM3.2UBTXDT6CKACA@etsalapatis.com>




> -----Original Messages-----
> From: "Emil Tsalapatis" <emil@etsalapatis.com>
> Send time:Wednesday, 17/06/2026 05:14:12
> To: "Nuoqi Gui" <gnq25@mails.tsinghua.edu.cn>, "Alexei Starovoitov" <ast@kernel.org>, "Daniel Borkmann" <daniel@iogearbox.net>, "Andrii
>  Nakryiko" <andrii@kernel.org>, "Eduard Zingerman" <eddyz87@gmail.com>, "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
> Cc: "John Fastabend" <john.fastabend@gmail.com>, "Martin KaFai Lau" <martin.lau@linux.dev>, "Luis Gerhorst" <luis.gerhorst@fau.de>, "Shuah
>  Khan" <shuah@kernel.org>, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
> Subject: Re: [PATCH bpf 2/2] selftests/bpf: Cover stack nospec slot indexing
> 
> On Tue Jun 16, 2026 at 12:57 PM EDT, Nuoqi Gui wrote:
> > Add a verifier test for the fixed-offset stack write case where two 4-byte
> > stores initialize opposite halves of the same stack slot.
> >
> > The test uses the CAP_BPF-without-CAP_PERFMON loader lane so Spectre v4
> > mitigation remains active. It expects both half-slot writes to emit nospec
> > in the translated program.
> >
> > Signed-off-by: Nuoqi Gui <gnq25@mails.tsinghua.edu.cn>
> 
> Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
> 
> Trivial style nits.
> 
> > ---
> >  .../testing/selftests/bpf/progs/verifier_unpriv.c  | 23 ++++++++++++++++++++++
> >  1 file changed, 23 insertions(+)
> >
> > diff --git a/tools/testing/selftests/bpf/progs/verifier_unpriv.c b/tools/testing/selftests/bpf/progs/verifier_unpriv.c
> > index c16f8382cf17d..9ebbd4b531df1 100644
> > --- a/tools/testing/selftests/bpf/progs/verifier_unpriv.c
> > +++ b/tools/testing/selftests/bpf/progs/verifier_unpriv.c
> > @@ -976,4 +976,27 @@ l0_%=:	exit;						\
> >  	: __clobber_all);
> >  }
> >  
> > +SEC("socket")
> > +__description("noperfmon: Spectre v4 stack write slot index")
> > +__success __success_unpriv
> > +__caps_unpriv(CAP_BPF)
> > +__retval(0)
> > +#ifdef SPEC_V4
> > +__xlated_unpriv("r0 = 0")
> > +__xlated_unpriv("*(u32 *)(r10 -4) = r0")
> > +__xlated_unpriv("nospec")
> > +__xlated_unpriv("*(u32 *)(r10 -8) = r0")
> 
> No whitespace to the right of -
> 
> > +__xlated_unpriv("nospec")
> > +__xlated_unpriv("exit")
> > +#endif
> > +__naked void stack_write_nospec_slot_index(void)
> > +{
> > +	asm volatile ("					\
> > +	r0 = 0;						\
> > +	*(u32 *)(r10 - 4) = r0;			\
> > +	*(u32 *)(r10 - 8) = r0;			\
> 
> Unaligned \ 
> 
> > +	exit;						\
> > +"	::: __clobber_all);
> > +}
> > +
> >  char _license[] SEC("license") = "GPL";

Thanks.

I'll fix the selftest formatting by adding the missing whitespace in the
__xlated_unpriv() strings and aligning the inline asm '\' markers.

  reply	other threads:[~2026-06-17 14:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16 16:57 [PATCH bpf 0/2] bpf: Fix stack slot index for Spectre v4 nospec checks Nuoqi Gui
2026-06-16 16:57 ` [PATCH bpf 1/2] bpf: Fix stack slot index in " Nuoqi Gui
2026-06-16 21:11   ` Emil Tsalapatis
2026-06-17  7:41   ` Luis Gerhorst
2026-06-17 11:08   ` Jiayuan Chen
2026-06-17 14:25     ` Nuoqi Gui
2026-06-16 16:57 ` [PATCH bpf 2/2] selftests/bpf: Cover stack nospec slot indexing Nuoqi Gui
2026-06-16 21:14   ` Emil Tsalapatis
2026-06-17 14:01     ` Nuoqi Gui [this message]
2026-06-17  8:45   ` Luis Gerhorst
2026-06-17 14:06     ` Nuoqi Gui

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=592abb4b.7e4ff.19ed5e2ff61.Coremail.gnq25@mails.tsinghua.edu.cn \
    --to=gnq25@mails.tsinghua.edu.cn \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=john.fastabend@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=luis.gerhorst@fau.de \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=shuah@kernel.org \
    /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®