From: sashiko-bot@kernel.org
To: "Richard Cheng" <icheng@nvidia.com>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH v8 3/4] cxl/region: Start unmapped poison scan at the committed decoder boundary
Date: Tue, 22 Sep 2026 10:29:59 +0000 [thread overview]
Message-ID: <20260922103000.88A861F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260922101129.52794-4-icheng@nvidia.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] cxl: integer underflow in cxl_get_poison_unmapped() from unmapped decoder offset
--
commit 8602a2ffbae3a910b43392bb444acb65b6b365e7
Author: Richard Cheng <icheng@nvidia.com>
cxl/region: Start unmapped poison scan at the committed decoder boundary
poison_by_decoder() stops at the last committed decoder and records the
handoff in ctx->offset, but cxl_get_poison_unmapped() ignores it and
starts after the highest DPA allocation instead. Allocation exist for
uncommitted decoders too, so their DPA is skipped by both phases and
poison there is never reported. Resume the scan at ctx->offset, and scan
later partitions in full, restoring the pre-rewrite behavior.
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 042356c71ed79..4869cdd6a3d48 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
[ ... ]
> @@ -2944,10 +2943,8 @@ static int cxl_get_poison_unmapped(struct cxl_memdev *cxlmd,
> */
> for (int i = ctx->part; i < cxlds->nr_partitions; i++) {
> res = &cxlds->part[i].res;
> - for (p = res->child, last = NULL; p; p = p->sibling)
> - last = p;
> - if (last)
> - offset = last->end + 1;
> + if (i == ctx->part)
> + offset = ctx->offset;
> + else
> + offset = res->start;
> length = res->end - offset + 1;
[Severity: High]
Does this code risk an integer underflow if offset is greater than res->end?
If poison_by_decoder() encounters a zero-sized commit_end decoder, it can
set ctx->part = -1 and ctx->offset = cxled->dpa_res->end + 1. If that
decoder was configured by firmware with a large skip value, ctx->offset can
be strictly greater than the end of the first partition (part[0].res.end).
Later, cxl_get_poison_by_endpoint() forces ctx.part = 0 before calling
cxl_get_poison_unmapped():
drivers/cxl/core/region.c:cxl_get_poison_by_endpoint() {
...
if (rc == 1) {
/* ... */
if (ctx.part < 0)
ctx.part = 0;
rc = cxl_get_poison_unmapped(to_cxl_memdev(port->uport_dev),
&ctx);
}
...
}
Because ctx.offset is not reset to part[0].res.start, offset is assigned
the out-of-bounds ctx->offset when i == 0. This causes the length
calculation to underflow in unsigned 64-bit arithmetic to an enormous
positive value.
Could this underflow bypass the !length check and result in sending an
invalid mailbox command to the hardware?
A massive out-of-bounds length passed directly to cxl_mem_get_poison() may
cause the CXL device to hang, time out, or process out-of-bounds requests,
leading to system instability.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260922101129.52794-1-icheng@nvidia.com?part=3
next prev parent reply other threads:[~2026-09-22 10:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 10:11 [PATCH v8 0/4] cxl: Repair poison enumeration regressions Richard Cheng
2026-09-22 10:11 ` [PATCH v8 1/4] cxl/region: Scan all partitions for unmapped poison Richard Cheng
2026-09-22 10:11 ` [PATCH v8 2/4] cxl/region: Don't leak tolerated RAM -EFAULT from unmapped poison scan Richard Cheng
2026-09-25 23:18 ` Jonathan Cameron
2026-09-22 10:11 ` [PATCH v8 3/4] cxl/region: Start unmapped poison scan at the committed decoder boundary Richard Cheng
2026-09-22 10:29 ` sashiko-bot [this message]
2026-09-22 10:11 ` [PATCH v8 4/4] cxl/memdev: Don't overwrite the error from an earlier partition poison query 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=20260922103000.88A861F00893@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