From: sashiko-bot@kernel.org
To: alistair23@gmail.com
Cc: linux-cxl@vger.kernel.org, ojeda@kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH v3 21/21] lib: rspdm: Support SPDM challenge
Date: Tue, 01 Sep 2026 01:31:03 +0000 [thread overview]
Message-ID: <20260901013103.7EA321F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901010347.2614656-22-alistair.francis@wdc.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [Medium] `ChallengeRsp` struct definition misrepresents the SPDM packet format by declaring variable-sized fields in the middle of a `repr(C, packed)` struct.
- [Medium] Missing upper bound check on transport response length (`rc`) in `challenge` function.
Pre-existing issues:
- [High] Stale `leaf_key` retention across multiple SPDM authentications causes persistent authentication failures.
--
commit fe7e9708b9e2dfbb56d50564eed90c6c3454e54e
Author: Alistair Francis <alistair@alistair23.me>
lib: rspdm: Support SPDM challenge
This commit adds support for the CHALLENGE SPDM command in the SPDM responder
implementation.
> diff --git a/lib/rspdm/state.rs b/lib/rspdm/state.rs
> index fc7df9dd7b973..1fd691037fa57 100644
> --- a/lib/rspdm/state.rs
> +++ b/lib/rspdm/state.rs
[ ... ]
> + fn verify_signature(&mut self, signature: &mut [u8]) -> Result<(), Error> {
[ ... ]
> + if let Some(leaf_key) = self.leaf_key {
> + unsafe { to_result(bindings::public_key_verify_signature(leaf_key, &sig)) }
> + } else {
> + return Err(EPROTO);
> + }
> + }
[Severity: High]
This is a pre-existing issue, but this code in verify_signature() relies on
the cached leaf_key which can lead to persistent authentication failures.
If a device is re-authenticated and its certificates have changed,
spdm_authenticate() will fetch the new certificates, but the existing code in
validate_cert_chain() only sets leaf_key if it is missing.
Will verify_signature() then attempt to verify the new signature using the
stale, previously cached leaf_key, resulting in an inevitable verification
failure during the challenge sequence?
[ ... ]
> + pub(crate) fn challenge(&mut self, slot: u8) -> Result<(), Error> {
[ ... ]
> + let rc = self.spdm_exchange(request_buf, response_vec.as_mut_slice())? as usize;
> +
> + // The transport must report a length within the buffer we provided.
> + if rc < core::mem::size_of::<ChallengeRsp>() {
> + pr_err!("Truncated challenge response\n");
> + return Err(EIO);
> + }
> + response_vec.truncate(rc);
[Severity: Medium]
Does SpdmState::challenge() miss the upper bound check on the transport
response length?
The comment notes that the transport must report a length within the buffer
provided. If a buggy transport driver returns an rc greater than
response_vec.len(), this check will pass and response_vec.truncate(rc) will
not bound the vector correctly, allowing the function to process potentially
uninitialized or out-of-bounds data later in the parsing process.
Should this also ensure that rc is less than or equal to response_vec.len()?
> diff --git a/lib/rspdm/validator.rs b/lib/rspdm/validator.rs
> index 2584bed739792..f623ac1d28606 100644
> --- a/lib/rspdm/validator.rs
> +++ b/lib/rspdm/validator.rs
[ ... ]
> +#[repr(C, packed)]
> +pub(crate) struct ChallengeRsp {
> + pub(crate) version: u8,
> + pub(crate) code: u8,
> + pub(crate) param1: u8,
> + pub(crate) param2: u8,
> +
> + pub(crate) cert_chain_hash: __IncompleteArrayField<u8>,
> + pub(crate) nonce: [u8; 32],
[Severity: Medium]
Does the ChallengeRsp struct definition in lib/rspdm/validator.rs misrepresent
the actual wire format of the SPDM protocol by placing a variable-sized field
before a fixed-size field?
Because __IncompleteArrayField<u8> acts as a zero-sized type, nonce and all
subsequent fields will be assigned static offsets that do not account for the
actual length of cert_chain_hash. Any future code attempting to access these
fields directly from the struct would read from the wrong offsets.
Does the struct layout need to be restructured to accurately reflect the
variable length nature of the SPDM challenge response?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260901010347.2614656-1-alistair.francis@wdc.com?part=21
prev parent reply other threads:[~2026-09-01 1:31 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 1:03 [PATCH v3 00/21] lib: Rust implementation of SPDM alistair23
2026-09-01 1:03 ` [PATCH v3 01/21] rust: transmute: add `cast_slice[_mut]` functions alistair23
2026-09-01 1:11 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 02/21] rust: create basic untrusted data API alistair23
2026-09-01 1:19 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 03/21] rust: validate: add `Validate` trait alistair23
2026-09-01 1:16 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 04/21] X.509: Make certificate parser public alistair23
2026-09-01 1:12 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 05/21] X.509: Parse Subject Alternative Name in certificates alistair23
2026-09-01 1:12 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 06/21] X.509: Move certificate length retrieval into new helper alistair23
2026-09-01 1:10 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 07/21] rust: add bindings for hash.h alistair23
2026-09-01 1:10 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 08/21] rust: error: impl From<FromBytesWithNulError> for Kernel Error alistair23
2026-09-01 1:10 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 09/21] lib: rspdm: Initial commit of Rust SPDM alistair23
2026-09-01 1:17 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 10/21] PCI/TSM: Rename pf0 to host alistair23
2026-09-01 1:16 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 11/21] PCI/TSM: Support connecting to PCIe CMA devices alistair23
2026-09-01 1:25 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 12/21] PCI/CMA: Add a PCI TSM CMA driver using SPDM alistair23
2026-09-01 1:20 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 13/21] PCI/CMA: Validate Subject Alternative Name in certificates alistair23
2026-09-01 1:15 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 14/21] lib: rspdm: Support SPDM get_version alistair23
2026-09-01 1:17 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 15/21] lib: rspdm: Support SPDM get_capabilities alistair23
2026-09-01 1:15 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 16/21] lib: rspdm: Support SPDM negotiate_algorithms alistair23
2026-09-01 1:30 ` sashiko-bot
2026-09-04 5:01 ` Aksh Garg
2026-09-01 1:03 ` [PATCH v3 17/21] lib: rspdm: Support SPDM get_digests alistair23
2026-09-01 1:20 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 18/21] lib: rspdm: Support SPDM get_certificate alistair23
2026-09-01 1:21 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 19/21] lib: rspdm: Support SPDM certificate validation alistair23
2026-09-01 1:22 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 20/21] rust: allow extracting the buffer from a CString alistair23
2026-09-01 1:19 ` sashiko-bot
2026-09-01 1:03 ` [PATCH v3 21/21] lib: rspdm: Support SPDM challenge alistair23
2026-09-01 1:31 ` sashiko-bot [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=20260901013103.7EA321F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alistair23@gmail.com \
--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