Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libbpf: fix signedness determination in CO-RE relo handling logic

Extracting btf_int_encoding() is only meaningful for BTF_KIND_INT, so we
need to check that first before inferring signedness.

Closes: https://github.com/libbpf/libbpf/issues/704
Reported-by: Lorenz Bauer <lmb@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20230824000016.2658017-2-andrii@kernel.org
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>

authored by

Andrii Nakryiko and committed by
Martin KaFai Lau
f3bdb54f a182e641

+1 -1
+1 -1
tools/lib/bpf/relo_core.c
··· 776 776 break; 777 777 case BPF_CORE_FIELD_SIGNED: 778 778 *val = (btf_is_any_enum(mt) && BTF_INFO_KFLAG(mt->info)) || 779 - (btf_int_encoding(mt) & BTF_INT_SIGNED); 779 + (btf_is_int(mt) && (btf_int_encoding(mt) & BTF_INT_SIGNED)); 780 780 if (validate) 781 781 *validate = true; /* signedness is never ambiguous */ 782 782 break;