All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Anisa Su" <anisa.su887@gmail.com>
Cc: nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org
Subject: Re: [PATCH v12 6/8] cxl/mem: Configure dynamic capacity interrupts
Date: Fri, 31 Jul 2026 09:04:43 +0000	[thread overview]
Message-ID: <20260731090444.558491F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260731084901.1512819-7-anisa.su@samsung.com>

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

New issues:
- [High] Infinite IRQ Thread Loop / CPU Spin when handling DCD events

Pre-existing issues:
- [High] Out-of-Bounds Read and Information Leak in Event logs
- [High] Out-of-Bounds Read and Information Leak in Poison logs
--

--- Patch [6]: [PATCH v12 6/8] cxl/mem: Configure dynamic capacity interrupts ---
commit 5b173c122c3602992c4ceeafd1c2d87a80accacb
Author: Ira Weiny <iweiny@kernel.org>

cxl/mem: Configure dynamic capacity interrupts

Dynamic Capacity Devices (DCD) support extent change notifications
through the event log mechanism. Configure DCD event log interrupts
on devices supporting dynamic capacity. Disable DCD if interrupts
are not supported.

> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> index df13fb8802c38..6cb344ec4f3a7 100644
> --- a/drivers/cxl/pci.c
> +++ b/drivers/cxl/pci.c
> @@ -509,11 +509,30 @@ static bool cxl_alloc_irq_vectors(struct pci_dev *pdev)
>  	return true;
>  }
>  
> +/*
> + * Event logs the driver drains: standard logs when native_cxl, DCD when
> + * supported.
> + */
> +static u32 cxl_event_drain_mask(struct pci_host_bridge *host_bridge,
> +				struct cxl_memdev_state *mds)
> +{
> +	u32 mask = 0;
> +
> +	if (host_bridge->native_cxl_error)
> +		mask |= CXLDEV_EVENT_STATUS_ALL & ~CXLDEV_EVENT_STATUS_DCD;
> +	if (cxl_dcd_supported(mds))
> +		mask |= CXLDEV_EVENT_STATUS_DCD;
> +	return mask;
> +}
> +
>  static irqreturn_t cxl_event_thread(int irq, void *id)
>  {
>  	struct cxl_dev_id *dev_id = id;
>  	struct cxl_dev_state *cxlds = dev_id->cxlds;
>  	struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlds);
> +	struct pci_host_bridge *host_bridge =
> +		pci_find_host_bridge(to_pci_dev(cxlds->dev)->bus);
> +	u32 mask = cxl_event_drain_mask(host_bridge, mds);
>  	u32 status;
>  
>  	do {
> @@ -522,8 +541,8 @@ static irqreturn_t cxl_event_thread(int irq, void *id)
>  		 * ignore the reserved upper 32 bits
>  		 */
>  		status = readl(cxlds->regs.status + CXLDEV_DEV_EVENT_STATUS_OFFSET);
> -		/* Ignore logs unknown to the driver */
> -		status &= CXLDEV_EVENT_STATUS_ALL;
> +		/* Ignore logs unknown to the driver or owned by BIOS */
> +		status &= mask;
>  		if (!status)
>  			break;
>  		cxl_mem_get_event_records(mds, status);

[Severity: High]
Since mask now includes CXLDEV_EVENT_STATUS_DCD, status can have this bit set.
However, cxl_mem_get_event_records() does not appear to handle the DCD event:

drivers/cxl/core/mbox.c:cxl_mem_get_event_records() {
    ...
    if (status & CXLDEV_EVENT_STATUS_FATAL)
        cxl_mem_get_records_log(mds, CXL_EVENT_TYPE_FATAL);
    if (status & CXLDEV_EVENT_STATUS_FAIL)
        cxl_mem_get_records_log(mds, CXL_EVENT_TYPE_FAIL);
    if (status & CXLDEV_EVENT_STATUS_WARN)
        cxl_mem_get_records_log(mds, CXL_EVENT_TYPE_WARN);
    if (status & CXLDEV_EVENT_STATUS_INFO)
        cxl_mem_get_records_log(mds, CXL_EVENT_TYPE_INFO);
    ...
}

Will this fail to clear the DCD event from the device? If the event is never
cleared, will the hardware register retain the bit and cause the while (status)
loop to spin infinitely on the exact same status bit, potentially causing a CPU
soft lockup?

>  		cond_resched();
>  	} while (status);

[ ... ]

[Severity: High]
This is a pre-existing issue, but I noticed a potential out-of-bounds read when
fetching event logs:

drivers/cxl/core/mbox.c:cxl_mem_get_records_log() {
    ...
    nr_rec = le16_to_cpu(payload->record_count);
    if (!nr_rec)
        break;

    for (i = 0; i < nr_rec; i++)
        __cxl_event_trace_record(cxlmd, type,
                                 &payload->records[i]);
    ...
}

Does this code validate the hardware-provided nr_rec against the allocated
payload size? If an untrusted or compromised device returns an artificially
large count, could this read out of bounds?

Similarly, when clearing those records:

drivers/cxl/core/mbox.c:cxl_clear_event_record() {
    ...
    for (cnt = 0; cnt < total; cnt++) {
        struct cxl_event_record_raw *raw = &get_pl->records[cnt];
        struct cxl_event_generic *gen = &raw->event.generic;

        payload->handles[i++] = gen->hdr.handle;
    ...
}

Could this write the out-of-bounds memory values into the clear event payload
sent back to the device, leading to an information leak?

[Severity: High]
This is also a pre-existing issue, but a similar pattern exists in the poison
log handling:

drivers/cxl/core/mbox.c:cxl_mem_get_poison() {
    ...
    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 validate po->count against the buffer size, or could it result
in an out-of-bounds read if the device returns a large count?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260731084901.1512819-1-anisa.su@samsung.com?part=6

  reply	other threads:[~2026-07-31  9:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31  8:48 [PATCH v12 0/8] DCD Prep Series Anisa Su
2026-07-31  8:48 ` [PATCH v12 1/8] cxl/mbox: Flag support for Dynamic Capacity Devices (DCD) Anisa Su
2026-07-31  8:48 ` [PATCH v12 2/8] cxl/mem: Read dynamic capacity configuration from the device Anisa Su
2026-07-31  9:01   ` sashiko-bot
2026-07-31  8:48 ` [PATCH v12 3/8] cxl/cdat: Gather DSMAS data for DCD partitions Anisa Su
2026-07-31  9:02   ` sashiko-bot
2026-07-31  8:48 ` [PATCH v12 4/8] cxl/events: Split event msgnum configuration from irq setup Anisa Su
2026-07-31  8:48 ` [PATCH v12 5/8] cxl/pci: Factor out interrupt policy check Anisa Su
2026-07-31  8:48 ` [PATCH v12 6/8] cxl/mem: Configure dynamic capacity interrupts Anisa Su
2026-07-31  9:04   ` sashiko-bot [this message]
2026-07-31  8:48 ` [PATCH v12 7/8] cxl/core: Return endpoint decoder information from region search Anisa Su
2026-07-31  9:01   ` sashiko-bot
2026-07-31  8:48 ` [PATCH v12 8/8] cxl/core: Enforce partition order/simplify partition calls Anisa Su

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=20260731090444.558491F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=anisa.su887@gmail.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    --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.