* [PATCH bpf] tools/headers: Regenerate stddef.h to fix BPF selftests
@ 2026-05-02 10:12 Paul Chaignon
2026-05-02 14:43 ` Alan Maguire
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Paul Chaignon @ 2026-05-02 10:12 UTC (permalink / raw)
To: bpf
Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Kumar Kartikeya Dwivedi
With commit dacbfc167808 ("crypto: af_alg - Annotate struct af_alg_iv
with __counted_by"), two selftests, test_tag and crypto_sanity, now
indirectly rely on the __counted_by macro. On systems with commit
dacbfc167808 in the installed UAPI headers, the selftests build fails
with:
In file included from tools/testing/selftests/bpf/prog_tests/crypto_sanity.c:7:
/usr/include/linux/if_alg.h:45:22: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘__counted_by’
45 | __u8 iv[] __counted_by(ivlen);
| ^~~~~~~~~~~~
This patch fixes it by regenerating stddef.h in tools/include using the
instructions from commit a778f5d46b62 ("tools/headers: Pull in stddef.h
to uapi to fix BPF selftests build in CI").
Fixes: dacbfc167808 ("crypto: af_alg - Annotate struct af_alg_iv with __counted_by")
Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
---
I'm a bit unsure if this should go to bpf or bpf-next, but it currently
applies cleanly to both.
tools/include/uapi/linux/stddef.h | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/tools/include/uapi/linux/stddef.h b/tools/include/uapi/linux/stddef.h
index c53cde425406..457498259494 100644
--- a/tools/include/uapi/linux/stddef.h
+++ b/tools/include/uapi/linux/stddef.h
@@ -3,7 +3,6 @@
#define _LINUX_STDDEF_H
-
#ifndef __always_inline
#define __always_inline __inline__
#endif
@@ -36,6 +35,11 @@
struct __struct_group_tag(TAG) { MEMBERS } ATTRS NAME; \
} ATTRS
+#ifdef __cplusplus
+/* sizeof(struct{}) is 1 in C++, not 0, can't use C version of the macro. */
+#define __DECLARE_FLEX_ARRAY(T, member) \
+ T member[0]
+#else
/**
* __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union
*
@@ -52,3 +56,23 @@
TYPE NAME[]; \
}
#endif
+
+#ifndef __counted_by
+#define __counted_by(m)
+#endif
+
+#ifndef __counted_by_le
+#define __counted_by_le(m)
+#endif
+
+#ifndef __counted_by_be
+#define __counted_by_be(m)
+#endif
+
+#ifndef __counted_by_ptr
+#define __counted_by_ptr(m)
+#endif
+
+#define __kernel_nonstring
+
+#endif /* _LINUX_STDDEF_H */
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH bpf] tools/headers: Regenerate stddef.h to fix BPF selftests
2026-05-02 10:12 [PATCH bpf] tools/headers: Regenerate stddef.h to fix BPF selftests Paul Chaignon
@ 2026-05-02 14:43 ` Alan Maguire
2026-05-02 16:05 ` Ihor Solodrai
2026-05-02 16:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Alan Maguire @ 2026-05-02 14:43 UTC (permalink / raw)
To: Paul Chaignon, bpf
Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Kumar Kartikeya Dwivedi
On 02/05/2026 11:12, Paul Chaignon wrote:
> With commit dacbfc167808 ("crypto: af_alg - Annotate struct af_alg_iv
> with __counted_by"), two selftests, test_tag and crypto_sanity, now
> indirectly rely on the __counted_by macro. On systems with commit
> dacbfc167808 in the installed UAPI headers, the selftests build fails
> with:
>
> In file included from tools/testing/selftests/bpf/prog_tests/crypto_sanity.c:7:
> /usr/include/linux/if_alg.h:45:22: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘__counted_by’
> 45 | __u8 iv[] __counted_by(ivlen);
> | ^~~~~~~~~~~~
>
> This patch fixes it by regenerating stddef.h in tools/include using the
> instructions from commit a778f5d46b62 ("tools/headers: Pull in stddef.h
> to uapi to fix BPF selftests build in CI").
>
> Fixes: dacbfc167808 ("crypto: af_alg - Annotate struct af_alg_iv with __counted_by")
> Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Thanks for the fix!
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
> ---
> I'm a bit unsure if this should go to bpf or bpf-next, but it currently
> applies cleanly to both.
>
> tools/include/uapi/linux/stddef.h | 26 +++++++++++++++++++++++++-
> 1 file changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/tools/include/uapi/linux/stddef.h b/tools/include/uapi/linux/stddef.h
> index c53cde425406..457498259494 100644
> --- a/tools/include/uapi/linux/stddef.h
> +++ b/tools/include/uapi/linux/stddef.h
> @@ -3,7 +3,6 @@
> #define _LINUX_STDDEF_H
>
>
> -
> #ifndef __always_inline
> #define __always_inline __inline__
> #endif
> @@ -36,6 +35,11 @@
> struct __struct_group_tag(TAG) { MEMBERS } ATTRS NAME; \
> } ATTRS
>
> +#ifdef __cplusplus
> +/* sizeof(struct{}) is 1 in C++, not 0, can't use C version of the macro. */
> +#define __DECLARE_FLEX_ARRAY(T, member) \
> + T member[0]
> +#else
> /**
> * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union
> *
> @@ -52,3 +56,23 @@
> TYPE NAME[]; \
> }
> #endif
> +
> +#ifndef __counted_by
> +#define __counted_by(m)
> +#endif
> +
> +#ifndef __counted_by_le
> +#define __counted_by_le(m)
> +#endif
> +
> +#ifndef __counted_by_be
> +#define __counted_by_be(m)
> +#endif
> +
> +#ifndef __counted_by_ptr
> +#define __counted_by_ptr(m)
> +#endif
> +
> +#define __kernel_nonstring
> +
> +#endif /* _LINUX_STDDEF_H */
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH bpf] tools/headers: Regenerate stddef.h to fix BPF selftests
2026-05-02 10:12 [PATCH bpf] tools/headers: Regenerate stddef.h to fix BPF selftests Paul Chaignon
2026-05-02 14:43 ` Alan Maguire
@ 2026-05-02 16:05 ` Ihor Solodrai
2026-05-02 16:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Ihor Solodrai @ 2026-05-02 16:05 UTC (permalink / raw)
To: Paul Chaignon, bpf
Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Kumar Kartikeya Dwivedi
On 5/2/26 11:12 AM, Paul Chaignon wrote:
> With commit dacbfc167808 ("crypto: af_alg - Annotate struct af_alg_iv
> with __counted_by"), two selftests, test_tag and crypto_sanity, now
> indirectly rely on the __counted_by macro. On systems with commit
> dacbfc167808 in the installed UAPI headers, the selftests build fails
> with:
>
> In file included from tools/testing/selftests/bpf/prog_tests/crypto_sanity.c:7:
> /usr/include/linux/if_alg.h:45:22: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘__counted_by’
> 45 | __u8 iv[] __counted_by(ivlen);
> | ^~~~~~~~~~~~
>
> This patch fixes it by regenerating stddef.h in tools/include using the
> instructions from commit a778f5d46b62 ("tools/headers: Pull in stddef.h
> to uapi to fix BPF selftests build in CI").
>
> Fixes: dacbfc167808 ("crypto: af_alg - Annotate struct af_alg_iv with __counted_by")
> Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Hi Paul, thank you for fixing this. You beat me to it :)
Can confirm the patch fixes selftests/bpf build on BPF CI:
https://github.com/kernel-patches/vmtest/actions/runs/25255756746/job/74054783017
Tested-by: Ihor Solodrai <ihor.solodrai@linux.dev>
> ---
> I'm a bit unsure if this should go to bpf or bpf-next, but it currently
> applies cleanly to both.
I think this should go through bpf tree, it's a clean fix.
>
> tools/include/uapi/linux/stddef.h | 26 +++++++++++++++++++++++++-
> 1 file changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/tools/include/uapi/linux/stddef.h b/tools/include/uapi/linux/stddef.h
> index c53cde425406..457498259494 100644
> --- a/tools/include/uapi/linux/stddef.h
> +++ b/tools/include/uapi/linux/stddef.h
> @@ -3,7 +3,6 @@
> #define _LINUX_STDDEF_H
>
>
> -
> #ifndef __always_inline
> #define __always_inline __inline__
> #endif
> @@ -36,6 +35,11 @@
> struct __struct_group_tag(TAG) { MEMBERS } ATTRS NAME; \
> } ATTRS
>
> +#ifdef __cplusplus
> +/* sizeof(struct{}) is 1 in C++, not 0, can't use C version of the macro. */
> +#define __DECLARE_FLEX_ARRAY(T, member) \
> + T member[0]
> +#else
> /**
> * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union
> *
> @@ -52,3 +56,23 @@
> TYPE NAME[]; \
> }
> #endif
> +
> +#ifndef __counted_by
> +#define __counted_by(m)
> +#endif
> +
> +#ifndef __counted_by_le
> +#define __counted_by_le(m)
> +#endif
> +
> +#ifndef __counted_by_be
> +#define __counted_by_be(m)
> +#endif
> +
> +#ifndef __counted_by_ptr
> +#define __counted_by_ptr(m)
> +#endif
> +
> +#define __kernel_nonstring
> +
> +#endif /* _LINUX_STDDEF_H */
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH bpf] tools/headers: Regenerate stddef.h to fix BPF selftests
2026-05-02 10:12 [PATCH bpf] tools/headers: Regenerate stddef.h to fix BPF selftests Paul Chaignon
2026-05-02 14:43 ` Alan Maguire
2026-05-02 16:05 ` Ihor Solodrai
@ 2026-05-02 16:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-05-02 16:40 UTC (permalink / raw)
To: Paul Chaignon; +Cc: bpf, ast, daniel, andrii, eddyz87, memxor
Hello:
This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Sat, 2 May 2026 12:12:40 +0200 you wrote:
> With commit dacbfc167808 ("crypto: af_alg - Annotate struct af_alg_iv
> with __counted_by"), two selftests, test_tag and crypto_sanity, now
> indirectly rely on the __counted_by macro. On systems with commit
> dacbfc167808 in the installed UAPI headers, the selftests build fails
> with:
>
> In file included from tools/testing/selftests/bpf/prog_tests/crypto_sanity.c:7:
> /usr/include/linux/if_alg.h:45:22: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘__counted_by’
> 45 | __u8 iv[] __counted_by(ivlen);
> | ^~~~~~~~~~~~
>
> [...]
Here is the summary with links:
- [bpf] tools/headers: Regenerate stddef.h to fix BPF selftests
https://git.kernel.org/bpf/bpf/c/0c7ae130698e
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-02 16:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-02 10:12 [PATCH bpf] tools/headers: Regenerate stddef.h to fix BPF selftests Paul Chaignon
2026-05-02 14:43 ` Alan Maguire
2026-05-02 16:05 ` Ihor Solodrai
2026-05-02 16:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox