* [PATCH] Check for NULL ptr of btf in codegen_asserts
@ 2022-05-23 19:49 Michael Mullin
2022-05-31 22:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Michael Mullin @ 2022-05-23 19:49 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
KP Singh, netdev, bpf, linux-kernel
bpf_object__btf() can return a NULL value. If bpf_object__btf returns
null, do not progress through codegen_asserts(). This avoids a null ptr
dereference at the call btf__type_cnt() in the function find_type_for_map()
Signed-off-by: Michael Mullin <masmullin@gmail.com>
---
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 4c9477ff748d..f158dc1c2149 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -474,6 +474,9 @@ static void codegen_asserts(struct bpf_object *obj, const char *obj_name)
const struct btf_type *sec;
char map_ident[256], var_ident[256];
+ if (!btf)
+ return;
+
codegen("\
\n\
__attribute__((unused)) static void \n\
--
2.36.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Check for NULL ptr of btf in codegen_asserts
2022-05-23 19:49 [PATCH] Check for NULL ptr of btf in codegen_asserts Michael Mullin
@ 2022-05-31 22:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-05-31 22:40 UTC (permalink / raw)
To: Michael Mullin
Cc: ast, daniel, andrii, kafai, songliubraving, yhs, john.fastabend,
kpsingh, netdev, bpf, linux-kernel
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Mon, 23 May 2022 15:49:17 -0400 you wrote:
> bpf_object__btf() can return a NULL value. If bpf_object__btf returns
> null, do not progress through codegen_asserts(). This avoids a null ptr
> dereference at the call btf__type_cnt() in the function find_type_for_map()
>
> Signed-off-by: Michael Mullin <masmullin@gmail.com>
> ---
> tools/bpf/bpftool/gen.c | 3 +++
> 1 file changed, 3 insertions(+)
Here is the summary with links:
- Check for NULL ptr of btf in codegen_asserts
https://git.kernel.org/bpf/bpf-next/c/d992a11f1171
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-31 22:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-23 19:49 [PATCH] Check for NULL ptr of btf in codegen_asserts Michael Mullin
2022-05-31 22:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).