]> git.baikalelectronics.ru Git - kernel.git/commitdiff
bpftool: Fix a wrong type cast in btf_dumper_int
authorLam Thai <lamthai@arista.com>
Wed, 24 Aug 2022 22:59:00 +0000 (15:59 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 11:22:22 +0000 (13:22 +0200)
[ Upstream commit 2d2587fe59799284a4af199b05e768b19d11e1e8 ]

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: a0fbb20d0b00 ("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>
tools/bpf/bpftool/btf_dumper.c

index 397e5716ab6d869f51496d29bd218f1a30eadf10..ebb73e4473103bb0fd803b4878b14b59a056d8e8 100644 (file)
@@ -251,7 +251,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 */