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 <[email protected]>
> ---
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.
...