From: "Cheatham, Benjamin" <benjamin.cheatham@amd.com>
To: Anisa Su <anisa.su887@gmail.com>, <linux-cxl@vger.kernel.org>
Subject: Re: [PATCH v2 2/4] cxl/events: Validate the record count reported by the device
Date: Tue, 1 Sep 2026 14:19:01 -0500 [thread overview]
Message-ID: <ae21fed6-014a-49b5-86c8-543d100fe26a@amd.com> (raw)
In-Reply-To: <20260901002912.958-3-anisa.su@samsung.com>
On 8/31/2026 7:26 PM, Anisa Su wrote:
> cxl_mem_get_records_log() takes the record count straight out of the Get
> Event Records payload and uses it to read from payload->records[].
> An oversized count reads past that buffer. Both
> __cxl_event_trace_record() and cxl_clear_event_record() use the record
> count to iterate oer payload->records[].
^ over>
> Bound the count by mbox_cmd.size_out which is already sanitized by
> __cxl_pci_mbox_send_cmd(). Report a bad record count as an error rather than a
> drained log, so a device repeating the bad count does not keep the event
> thread re-reading it.
>
> Fixes: 6ebe28f9ec72 ("cxl/mem: Read, trace, and clear events on driver load")
> Signed-off-by: Anisa Su <anisa.su@samsung.com>
> ---
> drivers/cxl/core/mbox.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
> index 2b71a8e1f35f..02b8c33a74b6 100644
> --- a/drivers/cxl/core/mbox.c
> +++ b/drivers/cxl/core/mbox.c
> @@ -1110,6 +1110,14 @@ static int cxl_mem_get_records_log(struct cxl_memdev_state *mds,
> nr_rec = le16_to_cpu(payload->record_count);
> if (!nr_rec)
> break;
> +
> + if (struct_size(payload, records, nr_rec) > mbox_cmd.size_out) {
> + dev_err_ratelimited(dev,
> + "Event log '%d': record count %u mismatch in %zu byte payload",
The units should probably match here, so either the record count should be the size in bytes or the
size_out should be the number of records expected.
With that:
Reviewed-by: Ben Cheatham <benjamin.cheatham@amd.com>
> + type, nr_rec, mbox_cmd.size_out);
> + rc = -EIO;
> + break;
> + }
> *got_records = true;
>
> for (i = 0; i < nr_rec; i++)
next prev parent reply other threads:[~2026-09-01 19:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 0:26 [PATCH v2 0/4] cxl/events: Robustify event interrupt handling Anisa Su
2026-09-01 0:26 ` [PATCH v2 1/4] cxl/events: Bound get records loop in cxl_event_thread() Anisa Su
2026-09-01 0:41 ` sashiko-bot
2026-09-01 11:48 ` Li Ming
2026-09-01 17:59 ` Anisa Su
2026-09-01 19:17 ` Cheatham, Benjamin
2026-09-01 0:26 ` [PATCH v2 2/4] cxl/events: Validate the record count reported by the device Anisa Su
2026-09-01 19:19 ` Cheatham, Benjamin [this message]
2026-09-01 0:26 ` [PATCH v2 3/4] cxl/events: Bound the per-log Get Event Records loop Anisa Su
2026-09-01 0:43 ` sashiko-bot
2026-09-01 19:19 ` Cheatham, Benjamin
2026-09-01 0:26 ` [PATCH v2 4/4] cxl/events: Return IRQ_NONE when no events were processed Anisa Su
2026-09-01 0:38 ` sashiko-bot
2026-09-01 19:19 ` Cheatham, Benjamin
2026-09-02 8:27 ` [PATCH v2 0/4] cxl/events: Robustify event interrupt handling Anisa Su
2026-09-02 19:06 ` Davidlohr Bueso
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=ae21fed6-014a-49b5-86c8-543d100fe26a@amd.com \
--to=benjamin.cheatham@amd.com \
--cc=anisa.su887@gmail.com \
--cc=linux-cxl@vger.kernel.org \
/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