Linux CXL
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: alistair23@gmail.com
Cc: linux-cxl@vger.kernel.org, linux-pci@vger.kernel.org,
	gary@garyguo.net, ojeda@kernel.org
Subject: Re: [PATCH v4 14/22] PCI/CMA: Validate Subject Alternative Name in certificates
Date: Mon, 28 Sep 2026 01:44:10 +0000	[thread overview]
Message-ID: <20260928014410.91F261F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260928011123.450800-15-alistair.francis@wdc.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] pci: case-sensitive SAN validation rejects uppercase hexadecimal device identities
- [High] pci: ASN.1 decoder aborts prematurely on certificates with multiple CMA SANs
--

commit 8216d5120f9a26d7f0a6ec14495fd951b1a7513d
Author: Lukas Wunner <lukas@wunner.de>

PCI/CMA: Validate Subject Alternative Name in certificates

This patch introduces validation for the Subject Alternative Name (SAN) in PCIe
leaf certificates per PCIe r6.1 specifications. It uses an ASN.1 decoder module
to parse and authenticate the identity encoding within the certificate's SAN
against the device's actual configuration space.

> diff --git a/drivers/pci/cma.c b/drivers/pci/cma.c
> index 6b52b129574ec..6e4eb3b921131 100644
> --- a/drivers/pci/cma.c
> +++ b/drivers/pci/cma.c

[ ... ]

> +int pci_cma_note_san(void *context, size_t hdrlen, unsigned char tag,
> +		     const void *value, size_t vlen)
> +{
> +	struct pci_cma_x509_context *ctx = context;
> +
> +	/* These aren't the drOIDs we're looking for. */
> +	if (ctx->last_oid != OID_CMA)
> +		return 0;
> +
> +	if (tag != ASN1_UTF8STR ||
> +	    vlen != ctx->expected_len ||
> +	    memcmp(value, ctx->expected_name, vlen) != 0) {

[Severity: High]
Will this strict memcmp() in pci_cma_note_san() fail if a device presents
a compliant SAN string using uppercase hexadecimal characters?

> +		pci_err(ctx->pdev, "Leaf certificate of slot %u "
> +			"has invalid Subject Alternative Name\n", ctx->slot);
> +		return -EINVAL;

[Severity: High]
Could returning -EINVAL here prematurely abort the ASN.1 decoding sequence
for certificates with multiple CMA SANs?

If a multi-function device shares a single leaf certificate containing
multiple Subject Alternative Name entries, aborting on the first mismatch
prevents the decoder from checking subsequent SANs that might legitimately
match the current PCIe function.

> +	}
> +
> +	ctx->found = true;
> +
> +	return 0;
> +}

[ ... ]

> +static unsigned int pci_cma_construct_san(struct pci_dev *pdev, char *name)
> +{
> +	unsigned int len;
> +	u64 serial;
> +
> +	len = scnprintf(name, CMA_NAME_MAX,
> +			"Vendor=%04hx:Device=%04hx:CC=%06x:REV=%02hhx",
> +			pdev->vendor, pdev->device, pdev->class, pdev->revision);

[Severity: High]
Is it possible that using lowercase formatting (%04hx) here inadvertently
causes the validation in pci_cma_note_san() to reject valid certificates
that encode their identity using uppercase hexadecimal characters?

> +
> +	if (pdev->hdr_type == PCI_HEADER_TYPE_NORMAL)
> +		len += scnprintf(name + len, CMA_NAME_MAX - len,
> +				 ":SSVID=%04hx:SSID=%04hx",
> +				 pdev->subsystem_vendor, pdev->subsystem_device);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260928011123.450800-1-alistair.francis@wdc.com?part=14

  reply	other threads:[~2026-09-28  1:44 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28  1:11 [PATCH v4 00/22] lib: Rust implementation of SPDM alistair23
2026-09-28  1:11 ` [PATCH v4 01/22] virt: coco: change tsm_register() to use a const struct alistair23
2026-09-28  1:41   ` sashiko-bot
2026-09-28  1:11 ` [PATCH v4 02/22] rust: transmute: add `cast_slice[_mut]` functions alistair23
2026-09-28  1:35   ` sashiko-bot
2026-09-28  1:11 ` [PATCH v4 03/22] rust: create basic untrusted data API alistair23
2026-09-28  1:41   ` sashiko-bot
2026-09-28  1:11 ` [PATCH v4 04/22] rust: validate: add `Validate` trait alistair23
2026-09-28  1:41   ` sashiko-bot
2026-09-28  1:11 ` [PATCH v4 05/22] X.509: Make certificate parser public alistair23
2026-09-28  1:39   ` sashiko-bot
2026-09-28  1:11 ` [PATCH v4 06/22] X.509: Parse Subject Alternative Name in certificates alistair23
2026-09-28  1:39   ` sashiko-bot
2026-09-28  1:11 ` [PATCH v4 07/22] X.509: Move certificate length retrieval into new helper alistair23
2026-09-28  1:36   ` sashiko-bot
2026-09-28  1:11 ` [PATCH v4 08/22] rust: add bindings for hash.h alistair23
2026-09-28  1:43   ` sashiko-bot
2026-09-28  1:11 ` [PATCH v4 09/22] rust: error: impl From<FromBytesWithNulError> for Kernel Error alistair23
2026-09-28  1:36   ` sashiko-bot
2026-09-28  1:11 ` [PATCH v4 10/22] lib: rspdm: Initial commit of Rust SPDM alistair23
2026-09-28  1:45   ` sashiko-bot
2026-09-28  1:11 ` [PATCH v4 11/22] PCI/TSM: Rename pf0 to host alistair23
2026-09-28  1:41   ` sashiko-bot
2026-09-28  1:11 ` [PATCH v4 12/22] PCI/TSM: Support connecting to PCIe CMA devices alistair23
2026-09-28  1:43   ` sashiko-bot
2026-09-28  1:11 ` [PATCH v4 13/22] PCI/CMA: Add a PCI TSM CMA driver using SPDM alistair23
2026-09-28  1:43   ` sashiko-bot
2026-09-28  1:11 ` [PATCH v4 14/22] PCI/CMA: Validate Subject Alternative Name in certificates alistair23
2026-09-28  1:44   ` sashiko-bot [this message]
2026-09-28  1:11 ` [PATCH v4 15/22] lib: rspdm: Support SPDM get_version alistair23
2026-09-28  1:39   ` sashiko-bot
2026-09-28  1:11 ` [PATCH v4 16/22] lib: rspdm: Support SPDM get_capabilities alistair23
2026-09-28  1:41   ` sashiko-bot
2026-09-28  1:11 ` [PATCH v4 17/22] lib: rspdm: Support SPDM negotiate_algorithms alistair23
2026-09-28  1:45   ` sashiko-bot
2026-09-28  1:11 ` [PATCH v4 18/22] lib: rspdm: Support SPDM get_digests alistair23
2026-09-28  1:45   ` sashiko-bot
2026-09-28  1:31 ` [PATCH v4 19/22] lib: rspdm: Support SPDM get_certificate alistair23
2026-09-28  1:31   ` [PATCH v4 20/22] lib: rspdm: Support SPDM certificate validation alistair23
2026-09-28  1:47     ` sashiko-bot
2026-09-28  1:31   ` [PATCH v4 21/22] rust: allow extracting the buffer from a CString alistair23
2026-09-28  1:41     ` sashiko-bot
2026-09-28  1:31   ` [PATCH v4 22/22] lib: rspdm: Support SPDM challenge alistair23
2026-09-28  1:46     ` sashiko-bot
2026-09-28  1:43   ` [PATCH v4 19/22] lib: rspdm: Support SPDM get_certificate 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=20260928014410.91F261F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alistair23@gmail.com \
    --cc=gary@garyguo.net \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=ojeda@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