Re: [PATCH] bpf: avoid padding in struct bpf_common_attr

From: Song Liu

Date: Tue May 19 2026 - 16:57:33 EST


On Tue, May 19, 2026 at 1:39 PM Arnd Bergmann <arnd@xxxxxxxxxx> wrote:
>
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> Building linux/bpf.h with -Wpadded shows an unintentionally
> added portion of padding because of the 64-bit alignment:
>
> ./usr/include/linux/bpf.h:1510:1: error: padding struct size to alignment boundary with 4 bytes [-Werror=padded]
>
> Avoid this by adding explicit padding.
>
> Fixes: f28771c0691b ("bpf: Extend BPF syscall with common attributes support")
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> ---
> include/uapi/linux/bpf.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index cc4c0b62cdfa..0f0ec00cae4a 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -1507,6 +1507,7 @@ struct bpf_common_attr {
> __u32 log_size;
> __u32 log_level;
> __u32 log_true_size;
> + __u32 __pad;
> };

Can we instead add "__attribute__((aligned(8)));" here?

Thanks,
Song

>
> #define BPF_OBJ_NAME_LEN 16U
> --
> 2.39.5
>