Skip to content

fix(migtd/spdm): make session failures atomic - #1028

Open
haitaohuang wants to merge 3 commits into
intel:mainfrom
haitaohuang:fix/spdm-responder-error-before-close
Open

haitaohuang wants to merge 3 commits into
intel:mainfrom
haitaohuang:fix/spdm-responder-error-before-close

Conversation

@haitaohuang

@haitaohuang haitaohuang commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Harden SPDM migration and rebind failure atomicity across three ordered commits:

  1. Propagate responder processing errors before interpreting a removed session as successful END_SESSION.
  2. Tear down every keyed requester/responder session on post-key-exchange failures, including timeout/cancellation paths, and perform best-effort transport shutdown without replacing the primary protocol error.
  3. Stage exchanged migration information and install the migration version, MSK, and approved SERVTD_EXT hash only after successful END_SESSION and transport shutdown. Responder exchange remains one-shot so replay cannot replace staged state.

The change preserves the existing quote and TDREPORT binding paths and does not import policy-series refactors, one-hash/CoRIM/RTMR1 changes, test bypasses, or diagnostic logging.

Validation

  • bash sh_script/preparation.sh
  • cargo fmt --check
  • cargo check
  • cargo test -p migtd --lib (23 passed)
  • Targeted SPDM Clippy (main,stack-guard,vmcall-raw,spdm_attestation,policy_v2)
  • Intel workflow Clippy (stack-guard,virtio-vsock,virtio-serial,vmcall-interrupt)
  • cargo deny check advisories, sources, and bans
  • cargo xtask lib-build and cargo xtask lib-test
  • All 32 Intel image matrix builds
  • All 14 current Intel integration-emu.yml scenarios, run sequentially

Evaluate the responder message result before treating a removed session as a successful END_SESSION. This preserves VDM and policy failures when the handler tears down the session.

Signed-off-by: Haitao Huang <haitaohuang@microsoft.com>
Assisted-by: GitHub Copilot CLI:GPT-5.6-Sol [migtd-review]
@haitaohuang haitaohuang changed the title fix(migtd/spdm): propagate errors before session close fix(migtd/spdm): make session failures atomic Sep 4, 2026
@sgrams

sgrams commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

It's a rather big change, I'll review next week

Invalidate requester and responder sessions on every failure after key
exchange, including timeout and transport-finalization paths. Always
attempt transport shutdown while preserving the primary protocol error.

FINISH clears runtime_info.last_session_id while the session remains
established. Cleanup based on that field therefore misses post-FINISH
timeouts, leaving session secrets live until context destruction. Tear down
all session slots owned by the exchange before transport shutdown, including
when the inner exchange future is cancelled.

Cover requester and responder cleanup with and without the handshake ID,
including secret reset and repeated cleanup. Run the regression coverage in
the library CI entry point with SPDM policy v1 and policy v2 enabled.

Signed-off-by: Haitao Huang <haitaohuang@microsoft.com>
Assisted-by: GitHub Copilot CLI:GPT-5.6-Sol
Assisted-by: GitHub Copilot CLI:gpt-6-astra
Stage peer migration information during the SPDM VDM exchange and commit the negotiated version, MSK, and approved SERVTD_EXT hash only after END_SESSION and transport shutdown complete successfully. Preserve one-shot responder handling so a replay cannot replace staged state.

Assisted-by: GitHub Copilot CLI:GPT-5.6-Sol [migtd-review]
Signed-off-by: Haitao Huang <haitaohuang@microsoft.com>
@haitaohuang
haitaohuang force-pushed the fix/spdm-responder-error-before-close branch from 02d0726 to f0c2a39 Compare September 8, 2026 19:34
haitaohuang added a commit to microsoft/MigTD that referenced this pull request Sep 9, 2026
Selectively backport the missing failure paths from intel#1028.
Retire all exchange-owned sessions through AppContextGuard, including
post-FINISH cancellation, before attempting transport shutdown. Preserve
the primary error and propagate every responder processing error.

Retain integration-specific helpers and application-buffer zeroization,
reset the responder exchange latch at entry, and adapt the upstream
cleanup regressions for both roles and cancellation. Existing state
staging and source EXPORT selection are already present.

Adapted from 7b40ecc and the responder
latch reset in f0c2a39.

Signed-off-by: Haitao Huang <haitaohuang@microsoft.com>
Assisted-by: GitHub Copilot CLI:gpt-6-astra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants