Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Yiyang Chen <chenyy23@mails.tsinghua.edu.cn>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: John Fastabend <john.fastabend@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>, Shuah Khan	 <shuah@kernel.org>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	Ihor Solodrai	 <ihor.solodrai@linux.dev>,
	bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
		linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 3/3] selftests/bpf: Cover commuted pointer state propagation
Date: Thu, 23 Jul 2026 14:18:49 -0700	[thread overview]
Message-ID: <f2dc5760f49efced48afa9a7f99317b35318aa7f.camel@gmail.com> (raw)
In-Reply-To: <c1023bb6c9e24d98cbe69f63e1df487f4d490108.1784696372.git.chenyy23@mails.tsinghua.edu.cn>

On Wed, 2026-07-22 at 05:27 +0000, Yiyang Chen wrote:
> Add verifier coverage for the three cases affected by preserving the full
> pointer state across scalar += pointer: stack frame number inheritance,
> readonly-untrusted memory access, and dynptr data-slice invalidation.
> 
> Signed-off-by: Yiyang Chen <chenyy23@mails.tsinghua.edu.cn>
> ---

Acked-by: Eduard Zingerman <eddyz87@gmail.com>

>  .../testing/selftests/bpf/progs/dynptr_fail.c | 31 ++++++++++++++
>  .../bpf/progs/mem_rdonly_untrusted.c          | 17 ++++++++
>  .../bpf/progs/verifier_basic_stack.c          | 41 +++++++++++++++++++
>  3 files changed, 89 insertions(+)
> 
> diff --git a/tools/testing/selftests/bpf/progs/dynptr_fail.c b/tools/testing/selftests/bpf/progs/dynptr_fail.c
> index 94489ac64da8e..7da4266bae09b 100644
> --- a/tools/testing/selftests/bpf/progs/dynptr_fail.c
> +++ b/tools/testing/selftests/bpf/progs/dynptr_fail.c
> @@ -1635,6 +1635,37 @@ static int callback(__u32 index, void *data)
>          return 0;
>  }
>  
> +/* A commuted add should preserve the parent id of a dynptr data slice.
> + */

Nit: comments style is:

  /* foo */

or

  /*
   * foo
   * bar
   */

> +SEC("?raw_tp")
> +__failure __msg("invalid mem access 'scalar'")
> +int dynptr_slice_commuted_invalidate(void *ctx)
> +{
> +	struct bpf_dynptr ptr;
> +	__u32 *slice, *derived;
> +
> +	bpf_ringbuf_reserve_dynptr(&ringbuf, sizeof(__u32), 0, &ptr);
> +
> +	slice = bpf_dynptr_data(&ptr, 0, sizeof(__u32));
> +	if (!slice)
> +		goto done;
> +
> +	asm volatile ("%[dst] = 0;"
> +		"%[dst] += %[src];"
> +		"%[src] = 0;"

Nit: no need to zero out 'src'?

> +		: [dst]"=&r"(derived), [src]"+r"(slice)
> +		:
> +		: "memory");
> +
> +	bpf_ringbuf_discard_dynptr(&ptr, 0);
> +	val = *derived;
> +	return 0;
> +
> +done:
> +	bpf_ringbuf_discard_dynptr(&ptr, 0);
> +	return 0;
> +}
> +

...

  reply	other threads:[~2026-07-23 21:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22  5:27 [PATCH bpf-next v3 0/3] bpf: Preserve pointer state for commuted arithmetic Yiyang Chen
2026-07-22  5:27 ` [PATCH bpf-next v3 1/3] " Yiyang Chen
2026-07-23  3:45   ` Shung-Hsi Yu
2026-07-23  4:25   ` Shung-Hsi Yu
2026-07-23 17:35     ` Eduard Zingerman
2026-07-23 17:57       ` Eduard Zingerman
2026-07-23 21:07   ` Eduard Zingerman
2026-07-24  3:05     ` Shung-Hsi Yu
2026-07-24  5:07       ` Eduard Zingerman
2026-07-22  5:27 ` [PATCH bpf-next v3 2/3] bpf: Propagate untrusted pointer state in " Yiyang Chen
2026-07-22  5:27 ` [PATCH bpf-next v3 3/3] selftests/bpf: Cover commuted pointer state propagation Yiyang Chen
2026-07-23 21:18   ` Eduard Zingerman [this message]
2026-07-22 11:38 ` [PATCH bpf-next v3 0/3] bpf: Preserve pointer state for commuted arithmetic Daniel Wade

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=f2dc5760f49efced48afa9a7f99317b35318aa7f.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=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