Skip to content

Commit ef3ba8c

Browse files
amiremohamadiAlexei Starovoitov
authored andcommitted
bpftool: fix potential NULL pointer dereferencing in prog_dump()
A NULL pointer dereference could occur if ksyms is not properly checked before usage in the prog_dump() function. Fixes: b053b43 ("bpf: libbpf: bpftool: Print bpf_line_info during prog dump") Signed-off-by: Amir Mohammadi <[email protected]> Reviewed-by: Quentin Monnet <[email protected]> Acked-by: John Fastabend <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent ac9a48a commit ef3ba8c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

tools/bpf/bpftool/prog.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -822,11 +822,18 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,
822822
printf("%s:\n", sym_name);
823823
}
824824

825-
if (disasm_print_insn(img, lens[i], opcodes,
826-
name, disasm_opt, btf,
827-
prog_linfo, ksyms[i], i,
828-
linum))
829-
goto exit_free;
825+
if (ksyms) {
826+
if (disasm_print_insn(img, lens[i], opcodes,
827+
name, disasm_opt, btf,
828+
prog_linfo, ksyms[i], i,
829+
linum))
830+
goto exit_free;
831+
} else {
832+
if (disasm_print_insn(img, lens[i], opcodes,
833+
name, disasm_opt, btf,
834+
NULL, 0, 0, false))
835+
goto exit_free;
836+
}
830837

831838
img += lens[i];
832839

0 commit comments

Comments
 (0)