From: sashiko-bot@kernel.org
To: "Arnaldo Carvalho de Melo" <acme@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 3/4] perf bpf: Add PROG_TAGS to required arrays in __bpf_event__print_bpf_prog_info()
Date: Sun, 02 Aug 2026 14:56:10 +0000 [thread overview]
Message-ID: <20260802145611.4A82B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260802142712.154726-4-acme@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Medium] The patch fixes an arbitrary memory read by adding PERF_BPIL_PROG_TAGS to required_arrays in __bpf_event__print_bpf_prog_info(), but fails to add corresponding validation for PERF_BPIL_FUNC_INFO, which is also accessed by synthesize_bpf_prog_name().
- [Medium] Missing validation for PERF_BPIL_LINE_INFO and PERF_BPIL_JITED_LINE_INFO before passing bpf_prog_info to bpf_prog_linfo__new().
--
--- Patch [3]: [PATCH 3/4] perf bpf: Add PROG_TAGS to required arrays in __bpf_event__print_bpf_prog_info() ---
commit 34f6adfee35f6522cc507083e8ec384e57659823
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf bpf: Add PROG_TAGS to required arrays in __bpf_event__print_bpf_prog_info()
This commit fixes an arbitrary memory read by ensuring PERF_BPIL_PROG_TAGS is
present in the required_arrays bitmask in __bpf_event__print_bpf_prog_info().
If the bit is cleared, prog_tags contains a raw file offset which causes a
crash on dereference.
> diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
> index fa3ebc8ea7f09..e67f28a8e92bd 100644
> --- a/tools/perf/util/bpf-event.c
> +++ b/tools/perf/util/bpf-event.c
> @@ -969,7 +969,8 @@ void __bpf_event__print_bpf_prog_info(struct perf_bpil *info_linear,
> {
> struct bpf_prog_info *info = &info_linear->info;
> __u64 required_arrays = (1UL << PERF_BPIL_JITED_KSYMS) |
> - (1UL << PERF_BPIL_JITED_FUNC_LENS);
> + (1UL << PERF_BPIL_JITED_FUNC_LENS) |
> + (1UL << PERF_BPIL_PROG_TAGS);
[Severity: Medium]
This is a pre-existing issue, but does required_arrays also need to include
PERF_BPIL_FUNC_INFO?
In synthesize_bpf_prog_name(), which is called later in this function, we do:
tools/perf/util/bpf-event.c:synthesize_bpf_prog_name() {
void *func_infos = (void *)(uintptr_t)(info->func_info);
...
if (btf &&
info->func_info_rec_size >= sizeof(*finfo) &&
sub_id < info->nr_func_info) {
finfo = func_infos + sub_id * info->func_info_rec_size;
t = btf__type_by_id(btf, finfo->type_id);
...
}
If a crafted perf.data file has nr_func_info > 0 but the PERF_BPIL_FUNC_INFO
bit is cleared in the array mask, info->func_info remains an untranslated raw
file offset, which could lead to an arbitrary memory read.
[Severity: Medium]
This isn't a bug introduced by this patch, but there appears to be a similar
missing validation for PERF_BPIL_LINE_INFO and PERF_BPIL_JITED_LINE_INFO
when disassembling:
tools/perf/util/libbfd.c:symbol__disassemble_bpf_libbfd() {
if (info_linear->info.nr_line_info)
prog_linfo = bpf_prog_linfo__new(&info_linear->info);
...
}
tools/lib/bpf/bpf_prog_linfo.c:bpf_prog_linfo__new() {
...
memcpy(prog_linfo->raw_linfo, (void *)(long)info->line_info, data_sz);
...
}
If the structure is blindly passed without checking if PERF_BPIL_LINE_INFO was
set and converted, info->line_info is dereferenced as an unvalidated raw file
offset in memcpy(). Could this cause an out-of-bounds read and crash?
> __u32 *prog_lens;
> __u64 *prog_addrs;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260802142712.154726-1-acme@kernel.org?part=3
next prev parent reply other threads:[~2026-08-02 14:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-02 14:27 [PATCHES 0/4] perf bpf hardening Arnaldo Carvalho de Melo
2026-08-02 14:27 ` [PATCH 1/4] perf libbfd: Validate BPF prog info arrays before pointer cast Arnaldo Carvalho de Melo
2026-08-02 14:54 ` sashiko-bot
2026-08-02 14:27 ` [PATCH 2/4] perf header: Use write lock when translating BPF prog info pointers Arnaldo Carvalho de Melo
2026-08-02 14:59 ` sashiko-bot
2026-08-02 14:27 ` [PATCH 3/4] perf bpf: Add PROG_TAGS to required arrays in __bpf_event__print_bpf_prog_info() Arnaldo Carvalho de Melo
2026-08-02 14:56 ` sashiko-bot [this message]
2026-08-02 14:27 ` [PATCH 4/4] perf libbfd: Fix memory leaks and NULL fclose in BPF disassembly Arnaldo Carvalho de Melo
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=20260802145611.4A82B1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=acme@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.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