bpftool/bpftool-Fix-a-wrong-type-cast-in-btf_dumper_int.patch
bitcoffee 4f4996a6e6 bpftool: init package
init package

Signed-off-by: bitcoffee <liuxin350@huawei.com>
2023-11-24 12:07:47 +08:00

39 lines
1.3 KiB
Diff

From 2afb93e4e4166a9b4022db58689986893a4c3653 Mon Sep 17 00:00:00 2001
From: Lam Thai <lamthai@arista.com>
Date: Wed, 24 Aug 2022 15:59:00 -0700
Subject: bpftool: Fix a wrong type cast in btf_dumper_int
[ Upstream commit 7184aef9c0f7a81db8fd18d183ee42481d89bf35 ]
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: b12d6ec09730 ("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>
---
src/btf_dumper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/btf_dumper.c b/src/btf_dumper.c
index 0e9310727281a..13be487631992 100644
--- a/src/btf_dumper.c
+++ b/src/btf_dumper.c
@@ -416,7 +416,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 */
--
cgit