public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bpftool: fix potential NULL pointer dereferencing in prog_dump()
@ 2024-11-15 11:45 Amir Mohammadi
  2024-11-15 13:42 ` Quentin Monnet
  0 siblings, 1 reply; 8+ messages in thread
From: Amir Mohammadi @ 2024-11-15 11:45 UTC (permalink / raw)
  To: qmo, ast, daniel, andrii, martin.lau, eddyz87, song,
	yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa, bpf,
	linux-kernel
  Cc: Amir Mohammadi

A NULL pointer dereference could occur if ksyms
is not properly checked before usage in the prog_dump() function.

Signed-off-by: Amir Mohammadi <amiremohamadi@yahoo.com>
---
 tools/bpf/bpftool/prog.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index 2ff949ea8..8b5300103 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -822,11 +822,12 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,
 					printf("%s:\n", sym_name);
 				}
 
-				if (disasm_print_insn(img, lens[i], opcodes,
-						      name, disasm_opt, btf,
-						      prog_linfo, ksyms[i], i,
-						      linum))
-					goto exit_free;
+				if (ksyms)
+					if (disasm_print_insn(img, lens[i], opcodes,
+							      name, disasm_opt, btf,
+							      prog_linfo, ksyms[i], i,
+							      linum))
+						goto exit_free;
 
 				img += lens[i];
 
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-11-25 22:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-15 11:45 [PATCH] bpftool: fix potential NULL pointer dereferencing in prog_dump() Amir Mohammadi
2024-11-15 13:42 ` Quentin Monnet
2024-11-16  7:13   ` [PATCH v2] " Amir Mohammadi
2024-11-21  6:34     ` John Fastabend
2024-11-21  8:34   ` [PATCH v3] " Amir Mohammadi
2024-11-21 11:18     ` Quentin Monnet
2024-11-21 23:29       ` John Fastabend
2024-11-25 22:30     ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox