From: sashiko-bot@kernel.org
To: alistair23@gmail.com
Cc: linux-pci@vger.kernel.org, linux-cxl@vger.kernel.org, ojeda@kernel.org
Subject: Re: [PATCH v2 21/21] lib: rspdm: Support SPDM challenge
Date: Tue, 23 Jun 2026 05:21:50 +0000 [thread overview]
Message-ID: <20260623052150.D80CD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260623045406.2589547-22-alistair.francis@wdc.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] A truncated SPDM capability response causes a kernel panic due to an out-of-bounds slice access.
- [High] Incorrect zero-padding placement in the SPDM 1.2+ combined prefix causes signature verification failure.
- [High] Incorrect memory layout passed to allocator when dropping `KVec` constructed via `from_raw_parts`.
--
commit 60ad79ffc915550973efe94b73f27dbe90a466d5
Author: Alistair Francis <alistair@alistair23.me>
lib: rspdm: Support SPDM challenge
Support the CHALLENGE SPDM command.
> diff --git a/lib/rspdm/state.rs b/lib/rspdm/state.rs
> index e381cf3f75f9e..7341d9d8a9310 100644
> --- a/lib/rspdm/state.rs
> +++ b/lib/rspdm/state.rs
[ ... ]
> @@ -463,12 +498,15 @@ pub(crate) fn get_capabilities(&mut self) -> 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 > response_vec.len() {
> + if rc > response_vec.len() || rc > rsp_sz {
> pr_err!("Overflowed capabilities response\n");
> return Err(EIO);
> }
> response_vec.truncate(rc);
>
> + self.transcript
> + .extend_from_slice(&response_vec[..rsp_sz], GFP_KERNEL)?;
[Severity: High]
If spdm_exchange() returns a smaller rc than rsp_sz, response_vec will be
truncated to rc elements. Will the slice &response_vec[..rsp_sz] then panic
due to being out of bounds?
[ ... ]
> @@ -971,4 +1028,175 @@ pub(crate) fn validate_cert_chain(&mut self, slot: u8) -> Result<(), Error> {
[ ... ]
> + let major = self.version >> 4;
> + let minor = self.version & 0xF;
> +
> + let output = CString::try_from_fmt(fmt!("dmtf-spdm-v{major:x}.{minor:x}.*dmtf-spdm-v{major:x}.{minor:x}.*dmtf-spdm-v{major:x}.{minor:x}.*dmtf-spdm-v{major:x}.{minor:x}.*"))?;
> + let mut buf = output.into_vec();
> + let zero_pad_len = SPDM_COMBINED_PREFIX_SZ - SPDM_PREFIX_SZ - SPDM_CONTEXT.len() - 1;
> +
> + buf.extend_with(zero_pad_len, 0, GFP_KERNEL)?;
> + buf.extend_from_slice(SPDM_CONTEXT.as_bytes(), GFP_KERNEL)?;
[Severity: High]
Does this code append the zero padding before the context string?
According to the SPDM 1.2+ specification (DSP0274), the combined prefix
format should be VersionPrefix || 0x00 || ContextString || ZeroPadding.
Could placing the zero padding before SPDM_CONTEXT cause the transcript hash
to mismatch the signature provided by the device?
[Severity: High]
Additionally, there appears to be a memory layout mismatch regression when
dropping the shash_desc context in SpdmState::drop() and
update_response_algs():
lib/rspdm/state.rs:SpdmState::drop() {
let desc_vec = unsafe { KVec::from_raw_parts(desc, desc_len, desc_len) };
drop(desc_vec);
}
Is the generic parameter T incorrectly inferred as bindings::shash_desc
instead of u8? Since desc_len is a byte count, would this pass the wrong
layout to the allocator during drop, assuming desc_len elements of type
shash_desc instead of desc_len bytes?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260623045406.2589547-1-alistair.francis@wdc.com?part=21
prev parent reply other threads:[~2026-06-23 5:21 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 4:53 [PATCH v2 00/21] lib: Rust implementation of SPDM alistair23
2026-06-23 4:53 ` [PATCH v2 01/21] rust: transmute: add `cast_slice[_mut]` functions alistair23
2026-06-23 5:05 ` sashiko-bot
2026-06-23 4:53 ` [PATCH v2 02/21] rust: create basic untrusted data API alistair23
2026-06-23 5:09 ` sashiko-bot
2026-06-23 4:53 ` [PATCH v2 03/21] rust: validate: add `Validate` trait alistair23
2026-06-23 5:10 ` sashiko-bot
2026-06-23 4:53 ` [PATCH v2 04/21] X.509: Make certificate parser public alistair23
2026-06-23 5:03 ` sashiko-bot
2026-06-23 4:53 ` [PATCH v2 05/21] X.509: Parse Subject Alternative Name in certificates alistair23
2026-06-23 5:07 ` sashiko-bot
2026-06-23 4:53 ` [PATCH v2 06/21] X.509: Move certificate length retrieval into new helper alistair23
2026-06-23 5:02 ` sashiko-bot
2026-06-23 4:53 ` [PATCH v2 07/21] rust: add bindings for hash.h alistair23
2026-06-23 7:01 ` sashiko-bot
2026-06-23 4:53 ` [PATCH v2 08/21] rust: error: impl From<FromBytesWithNulError> for Kernel Error alistair23
2026-06-23 5:01 ` sashiko-bot
2026-06-23 4:53 ` [PATCH v2 09/21] lib: rspdm: Initial commit of Rust SPDM alistair23
2026-06-23 5:09 ` sashiko-bot
2026-06-23 4:53 ` [PATCH v2 10/21] PCI/TSM: Rename pf0 to host alistair23
2026-06-23 5:12 ` sashiko-bot
2026-06-23 4:53 ` [PATCH v2 11/21] PCI/TSM: Support connecting to PCIe CMA devices alistair23
2026-06-23 5:16 ` sashiko-bot
2026-06-23 4:53 ` [PATCH v2 12/21] PCI/CMA: Add a PCI TSM CMA driver using SPDM alistair23
2026-06-23 5:07 ` sashiko-bot
2026-06-23 4:53 ` [PATCH v2 13/21] PCI/CMA: Validate Subject Alternative Name in certificates alistair23
2026-06-23 5:07 ` sashiko-bot
2026-06-23 4:53 ` [PATCH v2 14/21] lib: rspdm: Support SPDM get_version alistair23
2026-06-23 5:10 ` sashiko-bot
2026-06-23 4:54 ` [PATCH v2 15/21] lib: rspdm: Support SPDM get_capabilities alistair23
2026-06-23 5:09 ` sashiko-bot
2026-06-23 4:54 ` [PATCH v2 16/21] lib: rspdm: Support SPDM negotiate_algorithms alistair23
2026-06-23 5:17 ` sashiko-bot
2026-06-23 4:54 ` [PATCH v2 17/21] lib: rspdm: Support SPDM get_digests alistair23
2026-06-23 5:17 ` sashiko-bot
2026-06-23 4:54 ` [PATCH v2 18/21] lib: rspdm: Support SPDM get_certificate alistair23
2026-06-23 5:20 ` sashiko-bot
2026-06-23 4:54 ` [PATCH v2 19/21] lib: rspdm: Support SPDM certificate validation alistair23
2026-06-23 5:19 ` sashiko-bot
2026-06-23 4:54 ` [PATCH v2 20/21] rust: allow extracting the buffer from a CString alistair23
2026-06-23 5:13 ` sashiko-bot
2026-06-23 4:54 ` [PATCH v2 21/21] lib: rspdm: Support SPDM challenge alistair23
2026-06-23 5:21 ` 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=20260623052150.D80CD1F000E9@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