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 programs 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/20240422144538.351722-1-liuxin350@huawei.com/
  [3] https://lore.kernel.org/bpf/20230426055030.3743074-1-yhs@fb.com/

Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Reported-by: Xin Liu <liuxin350@huawei.com>
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Xin Liu <liuxin350@huawei.com>
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Cc: Alan Maguire <alan.maguire@oracle.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20240424223538.2682496-1-yonghong.song@linux.dev
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 file changed