* [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
* Re: [PATCH] bpftool: fix potential NULL pointer dereferencing in prog_dump()
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 8:34 ` [PATCH v3] " Amir Mohammadi
0 siblings, 2 replies; 8+ messages in thread
From: Quentin Monnet @ 2024-11-15 13:42 UTC (permalink / raw)
To: Amir Mohammadi, ast, daniel, andrii, martin.lau, eddyz87, song,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa, bpf,
linux-kernel
Cc: Amir Mohammadi
2024-11-15 15:15 UTC+0330 ~ Amir Mohammadi <amirmohammadi1999.am@gmail.com>
> 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];
>
Thanks! But we don't want to skip dumping the instruction silently if we
don't have ksyms. So we'd need an 'else' block that does the same as if
no JITed functions are found I think, something calling:
disasm_print_insn(img, lens[i], opcodes, name, disasm_opt, btf,
NULL, 0, 0, false)
Fixes: b053b439b72a ("bpf: libbpf: bpftool: Print bpf_line_info during prog dump")
Quentin
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] bpftool: fix potential NULL pointer dereferencing in prog_dump()
2024-11-15 13:42 ` Quentin Monnet
@ 2024-11-16 7:13 ` Amir Mohammadi
2024-11-21 6:34 ` John Fastabend
2024-11-21 8:34 ` [PATCH v3] " Amir Mohammadi
1 sibling, 1 reply; 8+ messages in thread
From: Amir Mohammadi @ 2024-11-16 7:13 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 | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index 2ff949ea8..e71be67f1 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -822,11 +822,18 @@ 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;
+ } else {
+ if (disasm_print_insn(img, lens[i], opcodes,
+ name, disasm_opt, btf,
+ NULL, 0, 0, false))
+ goto exit_free;
+ }
img += lens[i];
--
2.42.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* RE: [PATCH v2] bpftool: fix potential NULL pointer dereferencing in prog_dump()
2024-11-16 7:13 ` [PATCH v2] " Amir Mohammadi
@ 2024-11-21 6:34 ` John Fastabend
0 siblings, 0 replies; 8+ messages in thread
From: John Fastabend @ 2024-11-21 6:34 UTC (permalink / raw)
To: Amir Mohammadi, qmo, ast, daniel, andrii, martin.lau, eddyz87,
song, yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa,
bpf, linux-kernel
Cc: Amir Mohammadi
Amir Mohammadi wrote:
> 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 | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
LGTM but still needs a Fixes line.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3] bpftool: fix potential NULL pointer dereferencing in prog_dump()
2024-11-15 13:42 ` Quentin Monnet
2024-11-16 7:13 ` [PATCH v2] " Amir Mohammadi
@ 2024-11-21 8:34 ` Amir Mohammadi
2024-11-21 11:18 ` Quentin Monnet
2024-11-25 22:30 ` patchwork-bot+netdevbpf
1 sibling, 2 replies; 8+ messages in thread
From: Amir Mohammadi @ 2024-11-21 8:34 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.
Fixes: b053b439b72a ("bpf: libbpf: bpftool: Print bpf_line_info during prog dump")
Signed-off-by: Amir Mohammadi <amiremohamadi@yahoo.com>
---
tools/bpf/bpftool/prog.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index 2ff949ea8..e71be67f1 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -822,11 +822,18 @@ 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;
+ } else {
+ if (disasm_print_insn(img, lens[i], opcodes,
+ name, disasm_opt, btf,
+ NULL, 0, 0, false))
+ goto exit_free;
+ }
img += lens[i];
--
2.42.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v3] bpftool: fix potential NULL pointer dereferencing in prog_dump()
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
1 sibling, 1 reply; 8+ messages in thread
From: Quentin Monnet @ 2024-11-21 11:18 UTC (permalink / raw)
To: Amir Mohammadi, ast, daniel, andrii, martin.lau, eddyz87, song,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa, bpf,
linux-kernel
Cc: Amir Mohammadi
2024-11-21 12:04 UTC+0330 ~ Amir Mohammadi <amirmohammadi1999.am@gmail.com>
> 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>
Thanks!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3] bpftool: fix potential NULL pointer dereferencing in prog_dump()
2024-11-21 11:18 ` Quentin Monnet
@ 2024-11-21 23:29 ` John Fastabend
0 siblings, 0 replies; 8+ messages in thread
From: John Fastabend @ 2024-11-21 23:29 UTC (permalink / raw)
To: Quentin Monnet, Amir Mohammadi, ast, daniel, andrii, martin.lau,
eddyz87, song, yonghong.song, john.fastabend, kpsingh, sdf,
haoluo, jolsa, bpf, linux-kernel
Cc: Amir Mohammadi
Quentin Monnet wrote:
> 2024-11-21 12:04 UTC+0330 ~ Amir Mohammadi <amirmohammadi1999.am@gmail.com>
> > 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>
>
> Thanks!
Acked-by: John Fastabend <john.fastabend@gmail.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3] bpftool: fix potential NULL pointer dereferencing in prog_dump()
2024-11-21 8:34 ` [PATCH v3] " Amir Mohammadi
2024-11-21 11:18 ` Quentin Monnet
@ 2024-11-25 22:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-11-25 22:30 UTC (permalink / raw)
To: Amir Mohammadi
Cc: qmo, ast, daniel, andrii, martin.lau, eddyz87, song,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa, bpf,
linux-kernel, amiremohamadi
Hello:
This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Thu, 21 Nov 2024 12:04:13 +0330 you wrote:
> 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>
> ---
> tools/bpf/bpftool/prog.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
Here is the summary with links:
- [v3] bpftool: fix potential NULL pointer dereferencing in prog_dump()
https://git.kernel.org/bpf/bpf/c/ef3ba8c258ee
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [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