Skip to contentSkip to conversation

bpf: extend btf id list

PATCH In review Tom Rix 2 participants 2 messages Mar 7, 2023 – Apr 7, 2023 BPF

lore
Share & tools
lore

Tom Rix

author
#0 lore raw

PATCH 1/1 bpf: extend btf id list

With clang and W=1, there is this error

kernel/bpf/verifier.c:10298:24: error: array index 16 is past
the end of the array (that has type 'u32[16]'
(aka 'unsigned int[16]')) [-Werror,-Warray-bounds]

    meta.func_id == special_kfunc_list[KF_bpf_dynptr_slice_rdwr]) {
                    ^                  ~~~~~~~~~~~~~~~~~~~~~~~~

kernel/bpf/verifier.c:9150:1: note: array 'special_kfunc_list' declared here BTF_ID_LIST(special_kfunc_list)
^
./include/linux/btf_ids.h:207:27: note: expanded from macro 'BTF_ID_LIST'
#define BTF_ID_LIST(name) static u32 __maybe_unused name[16];

When KF_bpf_dynptr_slice_rdwr was added to the enum special_kfunc_type the total exceeded 16. Increase the array size to 32.

Fixes 66e3a13e7c2c ("bpf: Add bpf_dynptr_slice and bpf_dynptr_slice_rdwr")
---
 include/linux/btf_ids.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/btf_ids.h +1 -1
index 3a4f7cd882ca..166c387b48f7 100644
@@ -204,7 +204,7 @@ extern struct btf_id_set8 name;
 
 #else
 
-#define BTF_ID_LIST(name) static u32 __maybe_unused name[16];
+#define BTF_ID_LIST(name) static u32 __maybe_unused name[32];
 #define BTF_ID(prefix, name)
 #define BTF_ID_FLAGS(prefix, name, ...)
 #define BTF_ID_UNUSED
Signature · 1 line
2.27.0
#1 lore raw
Quoted 14 lines · Tom Rix

With clang and W=1, there is this error

kernel/bpf/verifier.c:10298:24: error: array index 16 is past
the end of the array (that has type 'u32[16]'
(aka 'unsigned int[16]')) [-Werror,-Warray-bounds]

    meta.func_id == special_kfunc_list[KF_bpf_dynptr_slice_rdwr]) {
                    ^                  ~~~~~~~~~~~~~~~~~~~~~~~~

kernel/bpf/verifier.c:9150:1: note: array 'special_kfunc_list' declared here BTF_ID_LIST(special_kfunc_list)
^
./include/linux/btf_ids.h:207:27: note: expanded from macro 'BTF_ID_LIST'
#define BTF_ID_LIST(name) static u32 __maybe_unused name[16];

Quoted 4 lines

When KF_bpf_dynptr_slice_rdwr was added to the enum special_kfunc_type the total exceeded 16. Increase the array size to 32.

Fixes 66e3a13e7c2c ("bpf: Add bpf_dynptr_slice and bpf_dynptr_slice_rdwr")

Looks like Nathan's patch got picked up.
commit 2d5bcdcda879 ("bpf: Increase size of BTF_ID_LIST without CONFIG_DEBUG_INFO_BTF again")
https://lore.kernel.org/bpf/[email protected]/

Quoted 22 lines
---
 include/linux/btf_ids.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/btf_ids.h +1 -2
index 3a4f7cd882ca..166c387b48f7 100644
@@ -204,7 +204,7 @@ extern struct btf_id_set8 name;
 
 #else
 
-#define BTF_ID_LIST(name) static u32 __maybe_unused name[16];
+#define BTF_ID_LIST(name) static u32 __maybe_unused name[32];
 #define BTF_ID(prefix, name)
 #define BTF_ID_FLAGS(prefix, name, ...)
 #define BTF_ID_UNUSED
--

2.27.0

Signature · 2 lines
Thanks,
~Nick Desaulniers