From: sashiko-bot@kernel.org
To: "Huang Shijie" <huangsj@hygon.cn>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf/amd/ibs: Report physical address for IBS fetch samples
Date: Thu, 03 Sep 2026 05:58:28 +0000 [thread overview]
Message-ID: <20260903055829.388C21F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260903054422.148739-1-huangsj@hygon.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Kernel stack buffer overflow when reading MSR_AMD64_IBSOPDATA4.
--
commit 7872bc1d9818cf858d57204bd43f4a048e54da52
Author: Huang Shijie <huangsj@hygon.cn>
perf/amd/ibs: Report physical address for IBS fetch samples
The IBS Fetch sampling does not report the physical address of the
fetched instruction even when PERF_SAMPLE_PHYS_ADDR is requested,
while IBS Op sampling does. This patch reports physical address for
IBS fetch samples which can be used for profiling the running program.
> diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
> index 3531f9c23b8c9..e5376ad5b2ecd 100644
> --- a/arch/x86/events/amd/ibs.c
> +++ b/arch/x86/events/amd/ibs.c
[ ... ]
> @@ -1555,6 +1575,8 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)
>
> if (perf_ibs == &perf_ibs_op)
> perf_ibs_parse_ld_st_data(event->attr.sample_type, &ibs_data, &data);
> + else
> + perf_ibs_parse_fetch_data(event->attr.sample_type, &ibs_data, &data);
[Severity: High]
This is a pre-existing issue, but does reading MSR_AMD64_IBSOPDATA4 earlier
in perf_ibs_handle_irq() overflow ibs_data.regs[] when both IBS_CAPS_BRNTRGT
and IBS_CAPS_OPDATA4 are present?
The ibs_data.regs array has a fixed size of MSR_AMD64_IBS_REG_COUNT_MAX (8).
If a user requests PERF_SAMPLE_RAW on a CPU supporting both features (like
Zen 4), the interrupt handler reads 7 base registers, an 8th register for
IBSBRTARGET, and a 9th for IBSOPDATA4.
This writes the 9th MSR value into ibs_data.regs[8] on the kernel stack:
if (ibs_caps & IBS_CAPS_OPDATA4) {
rdmsrq(MSR_AMD64_IBSOPDATA4, *buf++);
size++;
}
Can this corrupt adjacent stack memory when buf advances out of bounds?
>
> /*
> * rip recorded by IbsOpRip will not be consistent with rsp and rbp
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260903054422.148739-1-huangsj@hygon.cn?part=1
next prev parent reply other threads:[~2026-09-03 5:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 5:44 [PATCH] perf/amd/ibs: Report physical address for IBS fetch samples Huang Shijie
2026-09-03 5:58 ` sashiko-bot [this message]
2026-09-03 11:55 ` Ravi Bangoria
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=20260903055829.388C21F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=huangsj@hygon.cn \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.