Linux CXL
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: alejandro.lucero-palau@amd.com
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH v28 2/5] cxl/sfc: Map cxl regs
Date: Fri, 19 Jun 2026 17:24:44 +0000	[thread overview]
Message-ID: <20260619172444.EF0EF1F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260618181806.118745-3-alejandro.lucero-palau@amd.com>

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

Pre-existing issues:
- [High] `cxl_probe_component_regs()` performs unvalidated reads on the CXL component register block, which can cause a kernel panic if a malformed PCIe device exposes a small or truncated register block.
--

commit 0e4acdaa76943d29ebab4e0ccea9ab0230622629
Author: Alejandro Lucero <alucerop@amd.com>

cxl/sfc: Map cxl regs

Export cxl core functions for a Type2 driver being able to discover and
map the device registers.

Use it in sfc driver cxl initialization.

> diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c
> index be252af972ab3..704b0ebae9374 100644
> --- a/drivers/net/ethernet/sfc/efx_cxl.c
> +++ b/drivers/net/ethernet/sfc/efx_cxl.c
[ ... ]
> @@ -42,6 +45,29 @@ int efx_cxl_init(struct efx_probe_data *probe_data)
>  	if (!cxl)
>  		return -ENOMEM;
>  
> +	rc = cxl_pci_setup_regs(pci_dev, CXL_REGLOC_RBI_COMPONENT,
> +				&cxl->cxlds.reg_map);

[Severity: High]
This is a pre-existing issue, but when discovering the CXL register blocks,
cxl_decode_regblock() in drivers/cxl/core/regs.c computes the size of the
block as:

map->max_size = pci_resource_len(pdev, bar) - offset;

If a malicious or buggy device presents a Register Locator DVSEC with an
offset close to the end of the PCI BAR, map->max_size could be very small.

Later, cxl_probe_component_regs() blindly advances the base pointer by
CXL_CM_OFFSET (0x1000) and attempts to read the capability array:

base += CXL_CM_OFFSET;
cap_array = readl(base + CXL_CM_CAP_HDR_OFFSET);

Are there any bounds checks verifying that map->max_size is large enough
before these reads occur, or can this cause an out-of-bounds I/O memory
read and a kernel panic if a malformed PCIe device exposes a truncated
register block?

> +	if (rc) {
> +		pci_err(pci_dev, "No component registers\n");
> +		return rc;
> +	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260618181806.118745-1-alejandro.lucero-palau@amd.com?part=2

  parent reply	other threads:[~2026-06-19 17:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18 18:18 [PATCH v28 0/5] Type2 device basic support alejandro.lucero-palau
2026-06-18 18:18 ` [PATCH v28 1/5] sfc: add cxl support alejandro.lucero-palau
2026-06-19 13:12   ` Edward Cree
2026-06-19 17:24   ` sashiko-bot
2026-06-18 18:18 ` [PATCH v28 2/5] cxl/sfc: Map cxl regs alejandro.lucero-palau
2026-06-19 13:14   ` Edward Cree
2026-06-19 17:24   ` sashiko-bot [this message]
2026-06-18 18:18 ` [PATCH v28 3/5] cxl/sfc: Initialize dpa without a mailbox alejandro.lucero-palau
2026-06-19 13:15   ` Edward Cree
2026-06-19 17:24   ` sashiko-bot
2026-06-18 18:18 ` [PATCH v28 4/5] sfc: obtain and map cxl range using devm_cxl_probe_mem alejandro.lucero-palau
2026-06-18 23:05   ` Dave Jiang
2026-06-19 13:20   ` Edward Cree
2026-06-19 17:24   ` sashiko-bot
2026-06-18 18:18 ` [PATCH v28 5/5] sfc: support pio mapping based on cxl alejandro.lucero-palau
2026-06-18 23:06   ` Dave Jiang
2026-06-19 13:23   ` Edward Cree
2026-06-19 17:24   ` 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=20260619172444.EF0EF1F00A3E@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alejandro.lucero-palau@amd.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