Check for NULL ptr of btf in codegen_asserts
Subsystems (4)
PATCH 1/1 Check for NULL ptr of btf in codegen_asserts
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 <[email protected]>
--- tools/bpf/bpftool/gen.c | 3 +++ 1 file changed, 3 insertions(+)
tools/bpf/bpftool/gen.c +3 -0
@@ -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\
Signature · 1 line
2.36.1
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Quoted 8 lines · On Mon, 23 May 2022 15:49:17 -0400 you wrote:
bpf_object__btf()can return a NULL value. Ifbpf_object__btfreturns null, do not progress throughcodegen_asserts(). This avoids a null ptr dereference at the callbtf__type_cnt()in the functionfind_type_for_map()Signed-off-by Michael Mullin <[email protected]>--- 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html