From: Quentin Monnet <qmo@kernel.org>
To: Amir Mohammadi <amirmohammadi1999.am@gmail.com>,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
yonghong.song@linux.dev, john.fastabend@gmail.com,
kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
jolsa@kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Amir Mohammadi <amiremohamadi@yahoo.com>
Subject: Re: [PATCH] bpftool: fix potential NULL pointer dereferencing in prog_dump()
Date: Fri, 15 Nov 2024 13:42:56 +0000 [thread overview]
Message-ID: <47225498-12ab-4e69-ac50-2aab9dbe62c0@kernel.org> (raw)
In-Reply-To: <20241115114507.1322910-1-amiremohamadi@yahoo.com>
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
next prev parent reply other threads:[~2024-11-15 13:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 11:45 [PATCH] bpftool: fix potential NULL pointer dereferencing in prog_dump() Amir Mohammadi
2024-11-15 13:42 ` Quentin Monnet [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47225498-12ab-4e69-ac50-2aab9dbe62c0@kernel.org \
--to=qmo@kernel.org \
--cc=amiremohamadi@yahoo.com \
--cc=amirmohammadi1999.am@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox