Commit f3bdb54f authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Martin KaFai Lau

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/704Reported-by: default avatarLorenz Bauer <lmb@isovalent.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Acked-by: default avatarYonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20230824000016.2658017-2-andrii@kernel.orgSigned-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
parent a182e641
...@@ -776,7 +776,7 @@ static int bpf_core_calc_field_relo(const char *prog_name, ...@@ -776,7 +776,7 @@ static int bpf_core_calc_field_relo(const char *prog_name,
break; break;
case BPF_CORE_FIELD_SIGNED: case BPF_CORE_FIELD_SIGNED:
*val = (btf_is_any_enum(mt) && BTF_INFO_KFLAG(mt->info)) || *val = (btf_is_any_enum(mt) && BTF_INFO_KFLAG(mt->info)) ||
(btf_int_encoding(mt) & BTF_INT_SIGNED); (btf_is_int(mt) && (btf_int_encoding(mt) & BTF_INT_SIGNED));
if (validate) if (validate)
*validate = true; /* signedness is never ambiguous */ *validate = true; /* signedness is never ambiguous */
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment