Message ID | 20220523194917.igkgorco42537arb@jup (mailing list archive) |
---|---|
State | Accepted |
Commit | d992a11f11710ae10010e77654c8cee66d8f913b |
Delegated to: | BPF |
Headers | show |
Series | Check for NULL ptr of btf in codegen_asserts | expand |
Context | Check | Description |
---|---|---|
bpf/vmtest-bpf-next-PR | fail | PR summary |
bpf/vmtest-bpf-next-VM_Test-1 | success | Logs for Kernel LATEST on ubuntu-latest with gcc |
bpf/vmtest-bpf-next-VM_Test-2 | success | Logs for Kernel LATEST on ubuntu-latest with llvm-15 |
bpf/vmtest-bpf-next-VM_Test-3 | success | Logs for Kernel LATEST on z15 with gcc |
netdev/tree_selection | success | Not a local patch |
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!
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\
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(+)