Re: [PATCH v3] bpf: Replace bpf_lpm_trie_key 0-length array with flexible array

From: Kees Cook
Date: Tue Feb 20 2024 - 13:53:22 EST


On Tue, Feb 20, 2024 at 11:18:40AM +0100, Daniel Borkmann wrote:
> On 2/20/24 12:41 AM, Kees Cook wrote:
> > Replace deprecated 0-length array in struct bpf_lpm_trie_key with
> > flexible array. Found with GCC 13:
> [...]
> This fails the BPF CI :
>
> [...]
> INSTALL /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/include/bpf/skel_internal.h
> INSTALL /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/include/bpf/libbpf_version.h
> INSTALL /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/include/bpf/usdt.bpf.h
> In file included from urandom_read_lib1.c:7:
> In file included from /tmp/work/bpf/bpf/tools/lib/bpf/libbpf_internal.h:20:
> In file included from /tmp/work/bpf/bpf/tools/lib/bpf/relo_core.h:7:
> /tmp/work/bpf/bpf/tools/include/uapi/linux/bpf.h:91:2: error: type name requires a specifier or qualifier
> 91 | __struct_group(bpf_lpm_trie_key_hdr, hdr, /* no attrs */,
> | ^
> /tmp/work/bpf/bpf/tools/include/uapi/linux/bpf.h:91:58: error: expected identifier
> 91 | __struct_group(bpf_lpm_trie_key_hdr, hdr, /* no attrs */,
> | ^
> /tmp/work/bpf/bpf/tools/include/uapi/linux/bpf.h:93:18: error: unexpected ';' before ')'
> 93 | __u32 prefixlen;
> | ^
> /tmp/work/bpf/bpf/tools/include/uapi/linux/bpf.h:95:7: error: flexible array member 'data' not allowed in otherwise empty struct
> 95 | __u8 data[]; /* Arbitrary size */
> | ^

Ah-ha, my test build of cilium happened to cover up the lack of
stddef.h. Fixed now and sending a v4...

--
Kees Cook