From: Eduard Zingerman <eddyz87@gmail.com>
To: Jiayuan Chen <jiayuan.chen@linux.dev>, bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
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>,
Yazhou Tang <tangyazhou518@outlook.com>,
Amery Hung <ameryhung@gmail.com>,
Matt Bobrowski <mattbobrowski@google.com>,
Tejun Heo <tj@kernel.org>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH bpf 2/2] selftests/bpf: Test BTF walk into a flexible array of zero-sized elements
Date: Thu, 10 Sep 2026 15:01:18 -0700 [thread overview]
Message-ID: <9b3ca4f410cf1f2af0464df282fe017ae801bbd4.camel@gmail.com> (raw)
In-Reply-To: <20260910122316.186384-2-jiayuan.chen@linux.dev>
On Thu, 2026-09-10 at 20:22 +0800, Jiayuan Chen wrote:
> The program stashes a bpf_obj_new() object whose type ends with a flexible
> array of empty structs, then reads it back as an untrusted kptr. Without
> the previous patch this divides by zero in btf_struct_walk() instead of
> being rejected.
>
> # ./test_progs -t verifier_btf_flex_array
> ...
> #602 verifier_btf_flex_array:OK
> Summary: 1/1 PASSED, 0 SKIPPED, 0/0 FAILED
>
> Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
> ---
Please simplify test case as follows:
SEC("syscall")
__failure __msg("access beyond struct test_flex_batch at off 4 size 1")
int stash_and_peek(void *ctx)
{
struct map_value *v;
int key = 0;
v = bpf_map_lookup_elem(&batches, &key);
if (!v || !v->batch)
return 0;
return *(char *)&v->batch->events[0];
}
Also, aren't there already test cases for flex arrays somewhere?
Probably no need to add a new file.
...
next prev parent reply other threads:[~2026-09-10 22:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 12:22 [PATCH bpf 1/2] bpf: Fix divide-by-zero in btf_struct_walk() Jiayuan Chen
2026-09-10 12:22 ` [PATCH bpf 2/2] selftests/bpf: Test BTF walk into a flexible array of zero-sized elements Jiayuan Chen
2026-09-10 22:01 ` Eduard Zingerman [this message]
2026-09-10 21:49 ` [PATCH bpf 1/2] bpf: Fix divide-by-zero in btf_struct_walk() Eduard Zingerman
2026-09-11 0:00 ` 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=9b3ca4f410cf1f2af0464df282fe017ae801bbd4.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=ameryhung@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=jiayuan.chen@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mattbobrowski@google.com \
--cc=memxor@gmail.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=tangyazhou518@outlook.com \
--cc=tj@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.