From: sashiko-bot@kernel.org
To: "Richard Cheng" <icheng@nvidia.com>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH v6 5/7] cxl/memdev: Don't overwrite the error from an earlier partition poison query
Date: Wed, 26 Aug 2026 01:56:52 +0000 [thread overview]
Message-ID: <20260826015652.A64601F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260826014508.9989-6-icheng@nvidia.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Unvalidated `po->count` from hardware payload causes an out-of-bounds memory read that gets exposed to userspace via the `cxl_poison` tracepoint.
--
commit b8896ead9022e537cefc70198cd640048454c1cf
Author: Richard Cheng <icheng@nvidia.com>
cxl/memdev: Don't overwrite the error from an earlier partition poison query
cxl_get_poison_by_memdev() queries Get Poison List per partition but
never checks the result inside the loop, so a later partition's success
overwrites an earlier partition's failure and the whole scan reports
success while that partition's poison went unlisted. Before the loop
conversion the PMEM query returned early on error. Stop the loop on any
error not already tolerated as a RAM -EFAULT.
> diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
> index b3419df586b9c..e39b3d13fd566 100644
> --- a/drivers/cxl/core/memdev.c
> +++ b/drivers/cxl/core/memdev.c
> @@ -231,6 +231,8 @@ static int cxl_get_poison_by_memdev(struct cxl_memdev *cxlmd)
> */
> if (rc == -EFAULT && cxlds->part[i].mode == CXL_PARTMODE_RAM)
> rc = 0;
> + if (rc)
> + break;
> }
> return rc;
> }
[Severity: High]
This is a pre-existing issue, but I noticed a potential out-of-bounds read
triggered when cxl_get_poison_by_memdev() calls cxl_mem_get_poison() earlier
in this loop.
Looking at cxl_mem_get_poison() in drivers/cxl/core/mbox.c:
drivers/cxl/core/mbox.c:cxl_mem_get_poison() {
...
rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc)
break;
if (!le16_to_cpu(po->count)) {
dev_dbg(&cxlmd->dev, "Poison empty payload!\n");
break;
}
for (int i = 0; i < le16_to_cpu(po->count); i++)
trace_cxl_poison(cxlmd, cxlr, &po->record[i],
po->flags, po->overflow_ts,
CXL_POISON_TRACE_LIST);
...
}
Does this code trust the unvalidated po->count value from the hardware
payload?
If a device returns an artificially large po->count (up to 65535), the loop
appears to read beyond the bounds of the mds->poison.list_out buffer and expose
adjacent kernel memory to userspace via the cxl_poison tracepoint.
Could we bound po->count to mbox_cmd.size_out or the buffer capacity
to prevent this?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260826014508.9989-1-icheng@nvidia.com?part=5
next prev parent reply other threads:[~2026-08-26 1:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 1:45 [PATCH v6 0/7] cxl: Sashiko bug fixes Richard Cheng
2026-08-26 1:45 ` [PATCH v6 1/7] cxl/features: Reject feature offset that overflows 16-bit field Richard Cheng
2026-08-26 1:45 ` [PATCH v6 2/7] cxl/region: Scan all partitions for unmapped poison Richard Cheng
2026-08-26 1:57 ` sashiko-bot
2026-08-26 1:45 ` [PATCH v6 3/7] cxl/region: Don't leak tolerated RAM -EFAULT from unmapped poison scan Richard Cheng
2026-08-26 1:45 ` [PATCH v6 4/7] cxl/region: Start unmapped poison scan at the committed decoder boundary Richard Cheng
2026-08-26 1:45 ` [PATCH v6 5/7] cxl/memdev: Don't overwrite the error from an earlier partition poison query Richard Cheng
2026-08-26 1:56 ` sashiko-bot [this message]
2026-08-26 1:45 ` [PATCH v6 6/7] cxl/region: Reject poison scan for decoder without a partition Richard Cheng
2026-08-26 1:57 ` sashiko-bot
2026-08-26 1:45 ` [PATCH v6 7/7] cxl/fwctl: Propagate feature RPC delivery errors Richard Cheng
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=20260826015652.A64601F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=icheng@nvidia.com \
--cc=linux-cxl@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