Skip to content

Commit f3bdb54

Browse files
anakryikoMartin KaFai Lau
authored andcommitted
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: libbpf/libbpf#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>
1 parent a182e64 commit f3bdb54

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/lib/bpf/relo_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ static int bpf_core_calc_field_relo(const char *prog_name,
776776
break;
777777
case BPF_CORE_FIELD_SIGNED:
778778
*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));
780780
if (validate)
781781
*validate = true; /* signedness is never ambiguous */
782782
break;

0 commit comments

Comments
 (0)