Linux CXL
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Richard Cheng" <icheng@nvidia.com>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH v7 6/7] cxl/region: Reject poison scan for decoder without a partition
Date: Wed, 02 Sep 2026 05:52:41 +0000	[thread overview]
Message-ID: <20260902055241.AA4151F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260902053839.25595-7-icheng@nvidia.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Medium] Returning -ENODEV in poison_by_decoder() incorrectly aborts the iteration over the port's decoders, failing the entire poison scan.

Pre-existing issues:
- [High] The function `cxl_mem_get_poison` does not validate that the number of poison records returned by the device (`po->count`) fits within the allocated buffer, leading to an out-of-bounds read and information leak.
--

commit 38cab4750fe29ee2e45310ad8ff37111d581eb8d
Author: Richard Cheng <icheng@nvidia.com>
Subject: cxl/region: Reject poison scan for decoder without a partition

The __cxl_dpa_reserve() function may leave cxled->part at -1 when a
decoder's DPA range doesn't map to any reported partition. This commit
returns -ENODEV before accessing the partition array when no partition
was assigned.

> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index b7dc5d4988da7..afe3fb57b7fe2 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -2954,6 +2954,8 @@ static int poison_by_decoder(struct device *dev, void *arg)
>  	cxled = to_cxl_endpoint_decoder(dev);
>  	if (!cxled->dpa_res)
>  		return rc;
> +	if (cxled->part < 0)
> +		return -ENODEV;

[Severity: Medium]
Does returning -ENODEV in poison_by_decoder() incorrectly abort the iteration
over the port's decoders?

When a CXL port has an endpoint decoder that is not mapped to any partition,
the device_for_each_child() iteration will abort prematurely on the first
unmapped decoder. This prevents the remaining valid decoders from being
scanned for poison and skips cxl_get_poison_unmapped() entirely.

Could this return 0 instead to skip the unmapped decoder while allowing the
overall poison scan to continue?

This isn't a bug introduced by this patch, but I noticed another problem in
the cxl_mem_get_poison() function called later in this path:

drivers/cxl/core/mbox.c:cxl_mem_get_poison() {
    ...
		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);
    ...
}

[Severity: High]
Does this code overflow po->record[] if a buggy or malicious CXL device
returns a large po->count value?

The po->count value from the device payload is used to index the array
without being validated against the size of the list_out buffer allocated
via kvmalloc. If the firmware returns a large count value alongside a
small actual payload size, this could lead to an out-of-bounds read.

Can this leak adjacent kernel memory to the ftrace ring buffer or trigger a
kernel oops if the read crosses into an unmapped page?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260902053839.25595-1-icheng@nvidia.com?part=6

  reply	other threads:[~2026-09-02  5:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02  5:38 [PATCH v7 0/7] cxl: Sashiko bug fixes Richard Cheng
2026-09-02  5:38 ` [PATCH v7 1/7] cxl/features: Reject feature offset that overflows 16-bit field Richard Cheng
2026-09-04  5:23   ` Alison Schofield
2026-09-02  5:38 ` [PATCH v7 2/7] cxl/region: Scan all partitions for unmapped poison Richard Cheng
2026-09-02  5:38 ` [PATCH v7 3/7] cxl/region: Don't leak tolerated RAM -EFAULT from unmapped poison scan Richard Cheng
2026-09-04  5:25   ` Alison Schofield
2026-09-02  5:38 ` [PATCH v7 4/7] cxl/region: Start unmapped poison scan at the committed decoder boundary Richard Cheng
2026-09-02  5:38 ` [PATCH v7 5/7] cxl/memdev: Don't overwrite the error from an earlier partition poison query Richard Cheng
2026-09-04  5:31   ` Alison Schofield
2026-09-02  5:38 ` [PATCH v7 6/7] cxl/region: Reject poison scan for decoder without a partition Richard Cheng
2026-09-02  5:52   ` sashiko-bot [this message]
2026-09-04  5:57   ` Alison Schofield
2026-09-02  5:38 ` [PATCH v7 7/7] cxl/fwctl: Propagate feature RPC delivery errors Richard Cheng
2026-09-04  5:21   ` Alison Schofield
2026-09-04  5:20 ` [PATCH v7 0/7] cxl: Sashiko bug fixes Alison Schofield
2026-09-04 16:19 ` Dave Jiang

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=20260902055241.AA4151F00A3A@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