bpf: Fix build in minimal configurations, again
Subsystems (3)
PATCH 1/1 bpf: Fix build in minimal configurations, again
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.
--- kernel/bpf/btf.c | 1 + 1 file changed, 1 insertion(+)
kernel/bpf/btf.c +1 -0
@@ -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
Signature · 1 line
2.20.0
Quoted 21 lines · Arnd Bergmann
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 <[email protected]>--- kernel/bpf/btf.c | 1 + 1 file changed, 1 insertion(+)kernel/bpf/btf.c +0
-0
kernel/bpf/btf.c static u8 bpf_ctx_convert_map[] = { · line 3473
Quoted 4 lines
kernel/bpf/btf.c +1
-0@@ -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.
Quoted 6 lines · Arnd Bergmann
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;
Quoted 6 lines
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 <[email protected]>
Applied, thanks!