From: sashiko-bot@kernel.org
To: "Richard Cheng" <icheng@nvidia.com>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH v4 3/6] cxl/region: Don't leak tolerated RAM -EFAULT from unmapped poison scan
Date: Wed, 12 Aug 2026 12:08:26 +0000 [thread overview]
Message-ID: <20260812120827.53C061F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260812112107.56181-4-icheng@nvidia.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] cxl_get_poison_by_memdev() fails to break the loop on error, potentially overwriting a failing return code with a success return code from a subsequent partition.
--
--- Patch [3]: [PATCH v4 3/6] cxl/region: Don't leak tolerated RAM -EFAULT from unmapped poison scan ---
commit a0d57b2595f3317a70e0887bd131f7b1df706fef
Author: Richard Cheng <icheng@nvidia.com>
cxl/region: Don't leak tolerated RAM -EFAULT from unmapped poison scan
cxl_get_poison_unmapped() tolerates the -EFAULT a RAM partition returns
for Get Poison List by skipping that partition, but left rc holding the
error. If the tolerated RAM fault was the last poison query before the
loop ended, the function returned a spurious -EFAULT and the poison-list
read failed even though enumeration succeeded. Reset rc to 0 when
tolerating the fault, matching poison_by_decoder().
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index b03f30c04d350..ddf12075b95c0 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -2930,8 +2930,10 @@ static int cxl_get_poison_unmapped(struct cxl_memdev *cxlmd,
> if (!length)
> continue;
> rc = cxl_mem_get_poison(cxlmd, offset, length, NULL);
> - if (rc == -EFAULT && cxlds->part[i].mode == CXL_PARTMODE_RAM)
> + if (rc == -EFAULT && cxlds->part[i].mode == CXL_PARTMODE_RAM) {
> + rc = 0;
> continue;
> + }
> if (rc)
> break;
> }
[Severity: High]
This isn't a bug introduced by this patch, but was introduced in an earlier
commit be5cbd0840275 ("cxl: Kill enum cxl_decoder_mode"). Seeing the loop
here made me look at similar code in drivers/cxl/core/memdev.c.
Does cxl_get_poison_by_memdev() fail to break the loop on error?
drivers/cxl/core/memdev.c:cxl_get_poison_by_memdev() {
for (int i = 0; i < cxlds->nr_partitions; i++) {
const struct resource *res = &cxlds->part[i].res;
offset = res->start;
length = resource_size(res);
rc = cxl_mem_get_poison(cxlmd, offset, length, NULL);
/*
* Invalid Physical Address is not an error for
* volatile addresses. Device support is optional.
*/
if (rc == -EFAULT && cxlds->part[i].mode == CXL_PARTMODE_RAM)
rc = 0;
}
}
If cxl_mem_get_poison() fails for an early partition (like partition 0) due to
a hardware mailbox timeout and returns an error like -EIO, rc is set to the
error code. Since the loop lacks an if (rc) break; statement, it proceeds to
the next partition.
If the subsequent partition succeeds, rc is overwritten with 0, and the
function returns success. This masks the failure on partition 0 and leaves the
kernel unaware of poisoned memory.
Could this missing break statement lead to unhandled machine checks and
potential data corruption if that poisoned memory is accessed?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260812112107.56181-1-icheng@nvidia.com?part=3
next prev parent reply other threads:[~2026-08-12 12:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 11:21 [PATCH v4 0/6] cxl: Sashiko bug fixes Richard Cheng
2026-08-12 11:21 ` [PATCH v4 1/6] cxl/features: Reject feature offset that overflows 16-bit field Richard Cheng
2026-08-12 11:52 ` sashiko-bot
2026-08-12 11:21 ` [PATCH v4 2/6] cxl/region: Scan all partitions for unmapped poison Richard Cheng
2026-08-12 11:21 ` [PATCH v4 3/6] cxl/region: Don't leak tolerated RAM -EFAULT from unmapped poison scan Richard Cheng
2026-08-12 12:08 ` sashiko-bot [this message]
2026-08-12 11:21 ` [PATCH v4 4/6] cxl/region: Start unmapped poison scan at the committed decoder boundary Richard Cheng
2026-08-12 11:21 ` [PATCH v4 5/6] cxl/memdev: Don't overwrite the error from an earlier partition poison query Richard Cheng
2026-08-12 11:21 ` [PATCH v4 6/6] cxl/region: Reject poison scan for decoder without a partition Richard Cheng
2026-08-12 12:41 ` sashiko-bot
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=20260812120827.53C061F000E9@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 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.