linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bpf: Fix build in minimal configurations, again
@ 2019-12-10 20:35 Arnd Bergmann
  2019-12-10 23:34 ` Martin Lau
  2019-12-11 13:00 ` Daniel Borkmann
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2019-12-10 20:35 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Randy Dunlap
  Cc: Arnd Bergmann, Martin KaFai Lau, Song Liu, Yonghong Song,
	Andrii Nakryiko, Quentin Monnet, netdev, bpf, linux-kernel

Building with -Werror showed another failure:

kernel/bpf/btf.c: In function 'btf_get_prog_ctx_type.isra.31':
kernel/bpf/btf.c:3508:63: error: array subscript 0 is above array bounds of 'u8[0]' {aka 'unsigned char[0]'} [-Werror=array-bounds]
  ctx_type = btf_type_member(conv_struct) + bpf_ctx_convert_map[prog_type] * 2;

I don't actually understand why the array is empty, but a similar
fix has addressed a related problem, so I suppose we can do the
same thing here.

Fixes: ce27709b8162 ("bpf: Fix build in minimal configurations")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/bpf/btf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 7d40da240891..ed2075884724 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -3470,6 +3470,7 @@ static u8 bpf_ctx_convert_map[] = {
 	[_id] = __ctx_convert##_id,
 #include <linux/bpf_types.h>
 #undef BPF_PROG_TYPE
+	0, /* avoid empty array */
 };
 #undef BPF_MAP_TYPE
 
-- 
2.20.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] bpf: Fix build in minimal configurations, again
  2019-12-10 20:35 [PATCH] bpf: Fix build in minimal configurations, again Arnd Bergmann
@ 2019-12-10 23:34 ` Martin Lau
  2019-12-11 13:00 ` Daniel Borkmann
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Lau @ 2019-12-10 23:34 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Alexei Starovoitov, Daniel Borkmann, Randy Dunlap, Song Liu,
	Yonghong Song, Andrii Nakryiko, Quentin Monnet, netdev, bpf,
	linux-kernel

On Tue, Dec 10, 2019 at 09:35:46PM +0100, Arnd Bergmann wrote:
> Building with -Werror showed another failure:
> 
> kernel/bpf/btf.c: In function 'btf_get_prog_ctx_type.isra.31':
> kernel/bpf/btf.c:3508:63: error: array subscript 0 is above array bounds of 'u8[0]' {aka 'unsigned char[0]'} [-Werror=array-bounds]
>   ctx_type = btf_type_member(conv_struct) + bpf_ctx_convert_map[prog_type] * 2;
> 
> I don't actually understand why the array is empty, but a similar
> fix has addressed a related problem, so I suppose we can do the
> same thing here.
> 
> Fixes: ce27709b8162 ("bpf: Fix build in minimal configurations")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  kernel/bpf/btf.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index 7d40da240891..ed2075884724 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -3470,6 +3470,7 @@ static u8 bpf_ctx_convert_map[] = {
>  	[_id] = __ctx_convert##_id,
>  #include <linux/bpf_types.h>
>  #undef BPF_PROG_TYPE
> +	0, /* avoid empty array */
If bpf_types.h is empty, the prog should have already failed
earlier in find_prog_type() in syscall.c, so 0 here should
be fine.

Acked-by: Martin KaFai Lau <kafai@fb.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] bpf: Fix build in minimal configurations, again
  2019-12-10 20:35 [PATCH] bpf: Fix build in minimal configurations, again Arnd Bergmann
  2019-12-10 23:34 ` Martin Lau
@ 2019-12-11 13:00 ` Daniel Borkmann
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2019-12-11 13:00 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Alexei Starovoitov, Randy Dunlap, Martin KaFai Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, Quentin Monnet, netdev, bpf,
	linux-kernel

On Tue, Dec 10, 2019 at 09:35:46PM +0100, Arnd Bergmann wrote:
> Building with -Werror showed another failure:
> 
> kernel/bpf/btf.c: In function 'btf_get_prog_ctx_type.isra.31':
> kernel/bpf/btf.c:3508:63: error: array subscript 0 is above array bounds of 'u8[0]' {aka 'unsigned char[0]'} [-Werror=array-bounds]
>   ctx_type = btf_type_member(conv_struct) + bpf_ctx_convert_map[prog_type] * 2;
> 
> I don't actually understand why the array is empty, but a similar
> fix has addressed a related problem, so I suppose we can do the
> same thing here.
> 
> Fixes: ce27709b8162 ("bpf: Fix build in minimal configurations")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-11 13:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-10 20:35 [PATCH] bpf: Fix build in minimal configurations, again Arnd Bergmann
2019-12-10 23:34 ` Martin Lau
2019-12-11 13:00 ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).