[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240821133112.1467721-1-make24@iscas.ac.cn>
Date: Wed, 21 Aug 2024 21:31:12 +0800
From: Ma Ke <make24@...as.ac.cn>
To: qmo@...nel.org,
ast@...nel.org,
daniel@...earbox.net,
andrii@...nel.org,
martin.lau@...ux.dev,
eddyz87@...il.com,
song@...nel.org,
yonghong.song@...ux.dev,
john.fastabend@...il.com,
kpsingh@...nel.org,
sdf@...ichev.me,
haoluo@...gle.com,
jolsa@...nel.org,
delyank@...com
Cc: bpf@...r.kernel.org,
linux-kernel@...r.kernel.org,
Ma Ke <make24@...as.ac.cn>,
stable@...r.kernel.org
Subject: [PATCH] bpftool: check for NULL ptr of btf in codegen_subskel_datasecs
bpf_object__btf() can return NULL value. If bpf_object__btf returns null,
do not progress through codegen_subskel_datasecs(). This avoids a null ptr
dereference.
Found by code review, complie tested only.
Cc: stable@...r.kernel.org
Fixes: 00389c58ffe9 ("bpftool: Add support for subskeletons")
Signed-off-by: Ma Ke <make24@...as.ac.cn>
---
tools/bpf/bpftool/gen.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
index 5a4d3240689e..7ce62f280310 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -334,6 +334,9 @@ static int codegen_subskel_datasecs(struct bpf_object *obj, const char *obj_name
const char *sec_name, *var_name;
__u32 var_type_id;
+ if (!btf)
+ return -EINVAL;
+
d = btf_dump__new(btf, codegen_btf_dump_printf, NULL, NULL);
if (!d)
return -errno;
--
2.25.1
Powered by blists - more mailing lists