From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Alistair Francis" <alistair23@gmail.com>
Cc: "Alice Ryhl" <aliceryhl@google.com>, <lukas@wunner.de>,
<linux-cxl@vger.kernel.org>, <akpm@linux-foundation.org>,
<Jonathan.Cameron@huawei.com>, <rust-for-linux@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <jic23@kernel.org>,
<bhelgaas@google.com>, <alistair@alistair23.me>,
<djbw@kernel.org>, <linux-pci@vger.kernel.org>,
<wilfred.mallawa@wdc.com>, <a.hindborg@kernel.org>,
<gregkh@linuxfoundation.org>, <alex.gaynor@gmail.com>,
<benno.lossin@proton.me>, <boqun.feng@gmail.com>,
<bjorn3_gh@protonmail.com>, <tmgross@umich.edu>,
<gary@garyguo.net>, <ojeda@kernel.org>,
"Alistair Francis" <alistair.francis@wdc.com>
Subject: Re: [PATCH v4 00/22] lib: Rust implementation of SPDM
Date: Thu, 15 Oct 2026 17:02:40 +0900 [thread overview]
Message-ID: <DM596TT7E841.1U05OKY9N6I6C@nvidia.com> (raw)
In-Reply-To: <CAKmqyKOkmwompJqaP2k-oJicmXmqHY4E0wuLcrvkHLx+oauQ2Q@mail.gmail.com>
On Thu Oct 15, 2026 at 2:23 PM JST, Alistair Francis wrote:
> On Thu, Oct 15, 2026 at 6:54 AM Alice Ryhl <aliceryhl@google.com> wrote:
>>
>> On Mon, Sep 28, 2026 at 11:11:01AM +1000, alistair23@gmail.com wrote:
>> > From: Alistair Francis <alistair.francis@wdc.com>
>> >
>> > Security Protocols and Data Models (SPDM) [1] is used for authentication,
>> > attestation and key exchange. SPDM is generally used over a range of
>> > transports, such as PCIe, MCTP/SMBus/I3C, ATA, SCSI, NVMe or TCP.
>> >
>> > From the kernels perspective SPDM is used to authenticate and attest devices.
>> > In this threat model a device is considered untrusted until it can be verified
>> > by the kernel and userspace using SPDM. As such SPDM data is untrusted data
>> > that can be mallicious.
>> >
>> > The SPDM specification is also complex, with the 1.2.1 spec being almost 200
>> > pages and the 1.3.0 spec being almost 250 pages long.
>> >
>> > As such we have the kernel parsing untrusted responses from a complex
>> > specification, which sounds like a possible exploit vector. This is the type
>> > of place where Rust excels!
>> >
>> > This series implements a SPDM requester in Rust.
>>
>> So I looked a bit at this, and here are some comments. I will not repeat
>> what Alexandre has already said.
>>
>> First, I'd like to say that it's good to see that all wire-format
>> parsing in lib/rspdm/validator.rs is written in completely safe Rust.
>> That's exactly what we want to see for parsing in Rust. We want the code
>> to have basically no unsafe code whatsoever so that we really get to
>> rely on the bullet-proof guarantees about bugs being caught at compile
>> time, or at least at runtime.
>>
>> Unfortunately it looks like the same cannot be said for the state
>> machine in lib/rspdm/state.rs, which has way too much unsafe code in its
>> interaction with the rest of the kernel. There needs to be more
>> intermediate Rust abstractions here. This file should not have *any*
>> unsafe code, except maybe 1-2 blocks for using the C transport and
>> validate function pointers.
>
> Yeah, it's the crypto functions. There are currently no bindings, so
> it's just directly calling the C functions.
>
> Without the crypto functions it's just a single unsafe call to
> `transport_function()` in `state.rs` and a few in `lib.rs` to handl
> the C <-> FFI boundy.
>
> I was trying to avoid adding crypto and X.509 bindings in this series,
> as that's a few more subsystems this ends up touching. We need to add
> PQC as well, so crypto bindings are next on the todo list once this is
> merged.
>
> Is this going to stall on adding crypto bindings?
So without going all the way to fully-fledged crypto bindings, you will
spare yourself and your reviewers quite a bit of pain if you at least
implement a safe and lightweight crypto wrapper that is local to SPDM
and could eventually grow into official crypto bindings as a future
effort. As it is the code is very hard to review: for instance
`crypto_free_shash` is always called after `free_desc`, and looks like
it could/should be part of it, but that's hard to assess as the crypto
code is mixed with the rest and called here and there. I just cannot
tell whether all these unsafe blocks are safe of not, which is a problem
since the goal of writing this in Rust is to prevent exploits.
A self-contained crypto module exposing a safe interface would remove
that burden, reduce the number of `unsafe` blocks, and make the series
easier to review globally while not necessarily resulting in more code.
You just need to store the relevant pointers into a new data structure,
enforce the required invariants at construction time, and codify the
actions that SPDM is already doing in the form of methods.
prev parent reply other threads:[~2026-10-15 8:02 UTC|newest]
Thread overview: 56+ 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-10-14 15:16 ` Alexandre Courbot
2026-09-28 1:11 ` [PATCH v4 03/22] rust: create basic untrusted data API alistair23
2026-09-28 1:41 ` sashiko-bot
2026-10-14 15:17 ` Alexandre Courbot
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-10-14 15:17 ` Alexandre Courbot
2026-10-15 3:06 ` Alistair Francis
2026-10-15 7:29 ` Alexandre Courbot
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
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
2026-10-14 15:16 ` [PATCH v4 00/22] lib: Rust implementation of SPDM Alexandre Courbot
2026-10-15 4:17 ` Alistair Francis
2026-10-14 20:54 ` Alice Ryhl
2026-10-15 5:23 ` Alistair Francis
2026-10-15 5:54 ` Miguel Ojeda
2026-10-15 8:02 ` Alexandre Courbot [this message]
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=DM596TT7E841.1U05OKY9N6I6C@nvidia.com \
--to=acourbot@nvidia.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=a.hindborg@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=alistair.francis@wdc.com \
--cc=alistair23@gmail.com \
--cc=alistair@alistair23.me \
--cc=benno.lossin@proton.me \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=djbw@kernel.org \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=wilfred.mallawa@wdc.com \
/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.