From: sashiko-bot@kernel.org
To: alistair23@gmail.com, linux-pci@vger.kernel.org,
linux-cxl@vger.kernel.org
Cc: ojeda@kernel.org, gary@garyguo.net
Subject: Re: [PATCH v6 12/25] PCI/CMA: Add a PCI TSM CMA driver using SPDM
Date: Tue, 10 Nov 2026 04:41:33 +0000 [thread overview]
Message-ID: <sashiko-outbox-206226@kernel.org> (raw)
In-Reply-To: <20261110041832.1730924-13-alistair.francis@wdc.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] PCI/CMA: pci_cma_tsm_probe() misattaches subordinate and
sibling functions
- [Low] PCI/CMA: write-only static variable pci_cma_tsm_dev in
pci_cma_tsm_init()
--
commit 8928bf8b82ed0687cad0e8da916dd5dcfd9c6e73
Author: Alistair Francis <alistair.francis@wdc.com>
PCI/CMA: Add a PCI TSM CMA driver using SPDM
This commit adds a PCI TSM driver for Component Measurement and
Authentication (CMA-SPDM) over PCI DOE mailboxes, enabling device
authentication via SPDM.
> diff --git a/drivers/pci/cma.c b/drivers/pci/cma.c
> new file mode 100644
> index 0000000000000..3f0c989b52c5d
> --- /dev/null
> +++ b/drivers/pci/cma.c
[ ... ]
> +static struct pci_tsm *pci_cma_tsm_probe(struct tsm_dev *tsm_dev,
> + struct pci_dev *pdev)
> +{
> + struct pci_cma_tsm *cma;
> + int rc;
> +
> + if (!pdev->doe_cma || pdev->is_virtfn)
> + return NULL;
> +
> + cma = kzalloc(sizeof(*cma), GFP_KERNEL);
> + if (!cma)
> + return NULL;
> +
> + rc = pci_tsm_host_constructor(pdev, &cma->host, tsm_dev);
> + if (rc) {
> + kfree(cma);
> + return NULL;
> + }
> +
> + cma->spdm = spdm_create(&pdev->dev, pci_doe_transport, cma->host.doe_mb,
> + PCI_DOE_MAX_PAYLOAD, NULL);
> + if (!cma->spdm) {
> + pci_tsm_host_destructor(&cma->host);
> + kfree(cma);
> + return NULL;
> + }
> +
> + return &cma->host.base_tsm;
> +}
[Severity: High]
Can pci_cma_tsm_probe() attach subordinate or sibling functions without
authenticating them, and bind sibling functions' pci_tsm_host contexts to
function 0?
pci_cma_tsm_probe() succeeds for any physical function with pdev->doe_cma
set, even when called from probe_fn() for a subordinate function where
pci_cma_tsm_connect() is never run:
drivers/pci/tsm.c:probe_fn() {
...
pdev->tsm = ops->probe(dsm_dev->tsm->tsm_dev, pdev);
pci_dbg(pdev, "setup TSM context: DSM: %s status: %s\n",
pci_name(dsm_dev), pdev->tsm ? "success" : "failed");
if (pdev->tsm)
link_sysfs_enable(pdev);
return 0;
}
When a TEE-capable function 0 or upstream switch port is connected to
pci_cma_tsm (via pci_tsm_connect() -> pci_tsm_walk_fns()), or when a
sibling PF or downstream device is later initialized via pci_tsm_init()
while function 0 or the upstream port is connected, probe_fn() populates
pdev->tsm without calling spdm_authenticate(). Because authenticated_show()
reports the TSM device name whenever pdev->tsm is non-NULL, sysfs reports
those unauthenticated functions as authenticated and hides their tsm/connect
and tsm/disconnect attributes.
In addition, once function 0 is connected to pci_cma_tsm, is_dsm(pf0) is
true even on a non-TEE multi-function device:
drivers/pci/tsm.c:find_dsm_dev() {
...
if (pf0 && pf0 != pdev && is_dsm(pf0))
return pf0;
...
}
When a sibling PF is then connected via pci_tsm_connect() ->
pci_tsm_host_constructor() -> pci_tsm_link_constructor(), find_dsm_dev()
sets the sibling PF's base_tsm.dsm_dev to pf0 instead of the sibling PF
itself. That breaks the struct pci_tsm_host invariant (dsm_dev == pdev),
causing to_pci_tsm_host() and pci_tsm_doe_transfer() on the sibling PF to
use function 0's lock and DOE mailbox, hiding the sibling PF's disconnect
attribute, and causing __pci_tsm_destroy() to tear down the sibling PF via
pci_tsm_fn_exit() without holding tsm_host->lock.
[ ... ]
> +static struct tsm_dev *pci_cma_tsm_dev;
> +
> +static int __init pci_cma_tsm_init(void)
> +{
> + struct tsm_dev *tsm_dev;
> +
> + tsm_dev = tsm_register(NULL, &pci_cma_tsm_ops);
> + if (IS_ERR(tsm_dev))
> + return PTR_ERR(tsm_dev);
> +
> + pci_cma_tsm_dev = tsm_dev;
> + return 0;
> +}
[Severity: Low]
pci_cma_tsm_dev is assigned in pci_cma_tsm_init() but never read anywhere,
which triggers a -Wunused-but-set-variable warning under W=1.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261110041832.1730924-1-alistair.francis@wdc.com?part=12
next prev parent reply other threads:[~2026-11-10 4:41 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 4:18 [PATCH v6 00/25] lib: Rust implementation of SPDM alistair23
2026-11-10 4:18 ` [PATCH v6 01/25] virt: coco: change tsm_register() to use a const struct alistair23
2026-11-10 4:27 ` sashiko-bot
2026-11-12 2:39 ` Jonathan Cameron
2026-11-12 3:16 ` Alistair Francis
2026-11-10 4:18 ` [PATCH v6 02/25] rust: create basic untrusted data API alistair23
2026-11-10 4:34 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 03/25] rust: validate: add `Validate` trait alistair23
2026-11-10 4:26 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 04/25] X.509: Make certificate parser public alistair23
2026-11-10 4:26 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 05/25] X.509: Parse Subject Alternative Name in certificates alistair23
2026-11-10 4:26 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 06/25] X.509: Move certificate length retrieval into new helper alistair23
2026-11-10 4:27 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 07/25] rust: add bindings for hash.h alistair23
2026-11-10 4:30 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 08/25] rust: device: Expose Device as_raw() publicly alistair23
2026-11-10 4:26 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 09/25] lib: rspdm: Initial commit of Rust SPDM alistair23
2026-11-10 4:32 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 10/25] PCI/TSM: Rename pf0 to host alistair23
2026-11-10 4:28 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 11/25] PCI/TSM: Support connecting to PCIe CMA devices alistair23
2026-11-10 4:45 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 12/25] PCI/CMA: Add a PCI TSM CMA driver using SPDM alistair23
2026-11-10 4:41 ` sashiko-bot [this message]
2026-11-10 4:18 ` [PATCH v6 13/25] PCI/CMA: Validate Subject Alternative Name in certificates alistair23
2026-11-10 4:40 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 14/25] lib: rspdm: Support SPDM get_version alistair23
2026-11-10 4:32 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 15/25] lib: rspdm: Support SPDM get_capabilities alistair23
2026-11-10 4:38 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 16/25] rust: kernel: Add crypto hash bindings alistair23
2026-11-10 4:37 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 17/25] lib: rspdm: Support SPDM negotiate_algorithms alistair23
2026-11-10 4:42 ` sashiko-bot
2026-11-12 4:50 ` Alistair Francis
2026-11-10 4:18 ` [PATCH v6 18/25] lib: rspdm: Support SPDM get_digests alistair23
2026-11-10 4:42 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 19/25] lib: rspdm: Support SPDM get_certificate alistair23
2026-11-10 4:40 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 20/25] rust: public_key: Add crypto public key bindings alistair23
2026-11-10 4:47 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 21/25] keys: Guard asymmetric-type.h behind CONFIG_KEYS alistair23
2026-11-10 4:41 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 22/25] rust: x509: Add X509 certificate bindings alistair23
2026-11-10 4:54 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 23/25] lib: rspdm: Support SPDM certificate validation alistair23
2026-11-10 4:51 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 24/25] lib: rspdm: Support SPDM challenge alistair23
2026-11-10 4:49 ` sashiko-bot
2026-11-10 4:18 ` [PATCH v6 25/25] lib: rspdm: Expose public Rust API alistair23
2026-11-10 4:53 ` 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=sashiko-outbox-206226@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 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.