btf_encoder: Fix dwarf int type with greater-than-16 byte issue
Yonghong Song
reviewerPATCH 1/1 btf_encoder: Fix dwarf int type with greater-than-16 byte issue
Nick Desaulniers and Xin Liu separately reported that int type might have greater-than-16 byte size ([1] and [2]). More specifically, the reported int type sizes are 1024 and 64 bytes.
The libbpf and bpf program does not really support any int type greater than 16 bytes. Therefore, with current pahole, btf encoding will fail with greater-than-16 byte int types.
Since for now bpf does not support '> 16' bytes int type, the simplest way is to sanitize such types, similar to existing conditions like '!byte_sz' and 'byte_sz & (byte_sz - 1)'. This way, pahole won't call libbpf with an unsupported int type size. The patch [3] was proposed before. Now I resubmitted this patch as there are another failure due to the same issue.
[1] https://github.com/libbpf/libbpf/pull/680
[2] https://lore.kernel.org/bpf/[email protected]/
[3] https://lore.kernel.org/bpf/[email protected]/
--- btf_encoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
btf_encoder.c +1 -1
@@ -393,7 +393,7 @@ static int32_t btf_encoder__add_base_type(struct btf_encoder *encoder, const str* these non-regular int types to avoid libbpf/kernel complaints. */ byte_sz =BITS_ROUNDUP_BYTES (bt->bit_size); -if (!byte_sz || (byte_sz & (byte_sz -1 ))) { +if (!byte_sz || (byte_sz & (byte_sz -1 )) || byte_sz >16 ) { name ="__SANITIZED_FAKE_INT__" ; byte_sz =4 ; }
Signature · 1 line
2.43.0
Quoted 15 lines · Yonghong Song
Nick Desaulniers and Xin Liu separately reported that int type might have greater-than-16 byte size ([1] and [2]). More specifically, the reported int type sizes are 1024 and 64 bytes.
The libbpf and bpf program does not really support any int type greater than 16 bytes. Therefore, with current pahole, btf encoding will fail with greater-than-16 byte int types.
Since for now bpf does not support '> 16' bytes int type, the simplest way is to sanitize such types, similar to existing conditions like '!byte_sz' and '
byte_sz& (byte_sz- 1)'. This way, pahole won't call libbpf with an unsupported int type size. The patch [3] was proposed before. Now I resubmitted this patch as there are another failure due to the same issue.
Quoted 7 lines
[1] https://github.com/libbpf/libbpf/pull/680
[2] https://lore.kernel.org/bpf/[email protected]/
[3] https://lore.kernel.org/bpf/[email protected]/Cc Xin Liu <[email protected]>Cc Alan Maguire <[email protected]>Signed-off-by Yonghong Song <[email protected]>
Quoted 17 lines
--- btf_encoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)btf_encoder.c +1
-1@@ -393,7 +393,7 @@ static int32_t btf_encoder__add_base_type(struct btf_encoder *encoder, const str* these non-regular int types to avoid libbpf/kernel complaints. */ byte_sz =BITS_ROUNDUP_BYTES (bt->bit_size); -if (!byte_sz || (byte_sz & (byte_sz -1 ))) { +if (!byte_sz || (byte_sz & (byte_sz -1 )) || byte_sz >16 ) { name ="__SANITIZED_FAKE_INT__" ; byte_sz =4 ; }
Xin Liu
Reviewed-byQuoted 15 lines · On Wed, 24 Apr 2024 15:35:38 -0700 Yonghong Song <[email protected]>…
Nick Desaulniers and Xin Liu separately reported that int type might have greater-than-16 byte size ([1] and [2]). More specifically, the reported int type sizes are 1024 and 64 bytes.
The libbpf and bpf program does not really support any int type greater than 16 bytes. Therefore, with current pahole, btf encoding will fail with greater-than-16 byte int types.
Since for now bpf does not support '> 16' bytes int type, the simplest way is to sanitize such types, similar to existing conditions like '!byte_sz' and '
byte_sz& (byte_sz- 1)'. This way, pahole won't call libbpf with an unsupported int type size. The patch [3] was proposed before. Now I resubmitted this patch as there are another failure due to the same issue.
Quoted 7 lines
[1] https://github.com/libbpf/libbpf/pull/680
[2] https://lore.kernel.org/bpf/[email protected]/
[3] https://lore.kernel.org/bpf/[email protected]/Cc Xin Liu <[email protected]>Cc Alan Maguire <[email protected]>Signed-off-by Yonghong Song <[email protected]>
Quoted 17 lines
--- btf_encoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)btf_encoder.c +1
-1@@ -393,7 +393,7 @@ static int32_t btf_encoder__add_base_type(struct btf_encoder *encoder, const str* these non-regular int types to avoid libbpf/kernel complaints. */ byte_sz =BITS_ROUNDUP_BYTES (bt->bit_size); -if (!byte_sz || (byte_sz & (byte_sz -1 ))) { +if (!byte_sz || (byte_sz & (byte_sz -1 )) || byte_sz >16 ) { name ="__SANITIZED_FAKE_INT__" ; byte_sz =4 ; }
Arnaldo Carvalho de Melo
AppliedQuoted 20 lines · Xin Liu
Quoted 19 lines · On Wed, 24 Apr 2024 15:35:38 -0700 Yonghong Song <[email protected]>…
Nick Desaulniers and Xin Liu separately reported that int type might have greater-than-16 byte size ([1] and [2]). More specifically, the reported int type sizes are 1024 and 64 bytes.
The libbpf and bpf program does not really support any int type greater than 16 bytes. Therefore, with current pahole, btf encoding will fail with greater-than-16 byte int types.
Since for now bpf does not support '> 16' bytes int type, the simplest way is to sanitize such types, similar to existing conditions like '!byte_sz' and '
byte_sz& (byte_sz- 1)'. This way, pahole won't call libbpf with an unsupported int type size. The patch [3] was proposed before. Now I resubmitted this patch as there are another failure due to the same issue.[1] https://github.com/libbpf/libbpf/pull/680
[2] https://lore.kernel.org/bpf/[email protected]/
[3] https://lore.kernel.org/bpf/[email protected]/
Quoted 5 lines
Quoted 3 lines
Cc Xin Liu <[email protected]>Cc Alan Maguire <[email protected]>Signed-off-by Yonghong Song <[email protected]>Reviewed-by Xin Liu <[email protected]>
Thanks, applied to next,
- Arnaldo
Quoted 17 lines
Quoted 17 lines
--- btf_encoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)btf_encoder.c +1
-1@@ -393,7 +393,7 @@ static int32_t btf_encoder__add_base_type(struct btf_encoder *encoder, const str* these non-regular int types to avoid libbpf/kernel complaints. */ byte_sz =BITS_ROUNDUP_BYTES (bt->bit_size); -if (!byte_sz || (byte_sz & (byte_sz -1 ))) { +if (!byte_sz || (byte_sz & (byte_sz -1 )) || byte_sz >16 ) { name ="__SANITIZED_FAKE_INT__" ; byte_sz =4 ; }