Skip to content

Commit

Permalink
bpftool: Fix a wrong type cast in btf_dumper_int
Browse files Browse the repository at this point in the history
[ Upstream commit 7184aef ]

When `data` points to a boolean value, casting it to `int *` is problematic
and could lead to a wrong value being passed to `jsonw_bool`. Change the
cast to `bool *` instead.

Fixes: b12d6ec ("bpf: btf: add btf print functionality")
Signed-off-by: Lam Thai <lamthai@arista.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20220824225859.9038-1-lamthai@arista.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
lam-arista authored and gregkh committed Oct 21, 2022
1 parent 7e3472b commit e05472a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/bpf/bpftool/btf_dumper.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ static int btf_dumper_int(const struct btf_type *t, __u8 bit_offset,
*(char *)data);
break;
case BTF_INT_BOOL:
jsonw_bool(jw, *(int *)data);
jsonw_bool(jw, *(bool *)data);
break;
default:
/* shouldn't happen */
Expand Down

0 comments on commit e05472a

Please sign in to comment.