Re: [PATCH v2][next] bpf: Avoid thousands of -Wflex-array-members-not-at-end warnings

From: Alexei Starovoitov

Date: Sun Apr 05 2026 - 22:45:15 EST


On Mon, Mar 30, 2026 at 3:39 PM Gustavo A. R. Silva
<gustavoars@xxxxxxxxxx> wrote:
>
> Apparently, struct bpf_empty_prog_array exists entirely to populate a
> single element of "items" in a global variable. "null_prog" is only
> used during the initializer.
>
> None of this is needed; globals will be correctly sized with an array
> initializer of a flexible-array member.
>
> So, remove struct bpf_empty_prog_array and adjust the rest of the code,
> accordingly.
>
> With these changes, fix the following warnings:
>
> 7659 ./include/linux/bpf.h:2369:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
>
> Signed-off-by: Gustavo A. R. Silva <gustavoars@xxxxxxxxxx>
> ---
> Changes in v2:
> - Remove struct bpf_empty_prog_array. (Kees)

Kees,

It really bothers me that you ask people to clean up
warnings for the sake of removing warnings.

This has to stop.

This patch adds a ticking time bomb.
See bpf_prog_run_array_cg() and think why it's an exploit
waiting to happen.

Fixing -Wflex-array-member-not-at-end warnings make the kernel more secure...
It's the opposite!
Such crusade against warnings introduces subtle bugs.

Look, this patch was Acked. bpf CI is green.
No failing tests and I was about to apply it,
since it looked correct on the first glance,
but something felt wrong...
'null_prog' was there for a reason.

I so hate this "hardening" cleanups that introduce bugs.

pw-bot: cr