Commit ef3ba8c2 authored by Amir Mohammadi's avatar Amir Mohammadi Committed by Alexei Starovoitov
Browse files

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: b053b439 ("bpf: libbpf: bpftool: Print bpf_line_info during prog dump")
Signed-off-by: default avatarAmir Mohammadi <amiremohamadi@yahoo.com>
Reviewed-by: default avatarQuentin Monnet <qmo@kernel.org>
Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/r/20241121083413.7214-1-amiremohamadi@yahoo.com


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent ac9a48a6
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -822,11 +822,18 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,
					printf("%s:\n", sym_name);
				}

				if (ksyms) {
					if (disasm_print_insn(img, lens[i], opcodes,
							      name, disasm_opt, btf,
							      prog_linfo, ksyms[i], i,
							      linum))
						goto exit_free;
				} else {
					if (disasm_print_insn(img, lens[i], opcodes,
							      name, disasm_opt, btf,
							      NULL, 0, 0, false))
						goto exit_free;
				}

				img += lens[i];