Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: b053b439b72a ("bpf: libbpf: bpftool: Print bpf_line_info during prog dump")
Signed-off-by: Amir Mohammadi <amiremohamadi@yahoo.com>
Reviewed-by: Quentin Monnet <qmo@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/r/20241121083413.7214-1-amiremohamadi@yahoo.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Amir Mohammadi and committed by
Alexei Starovoitov
ef3ba8c2 ac9a48a6

+12 -5
+12 -5
tools/bpf/bpftool/prog.c
··· 822 822 printf("%s:\n", sym_name); 823 823 } 824 824 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 + } 830 837 831 838 img += lens[i]; 832 839