Skip to content

Conversation

@IntelCaisui
Copy link
Contributor

@IntelCaisui IntelCaisui commented Nov 21, 2025

Wrap the pre-session v2 policy change with a timeout to prevent potential
hang during pre migration.
Fix problem 1 of issue: #603

@IntelCaisui IntelCaisui requested a review from jyao1 as a code owner November 21, 2025 05:41
@IntelCaisui IntelCaisui reopened this Nov 21, 2025
@liuw1 liuw1 requested a review from Copilot November 21, 2025 08:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds timeout protection for the pre-session v2 policy exchange to prevent potential hangs during migration, addressing issue #603. The changes refactor timeout constant definitions to be scoped closer to their usage points.

Key changes:

  • Wraps the pre-session policy exchange with a 60-second timeout
  • Moves timeout constant definitions from global scope to function scope
  • Consolidates timeout constant declarations for better code organization

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/migtd/src/spdm/mod.rs Removes global SPDM_TIMEOUT constant definition
src/migtd/src/migration/session.rs Adds timeout wrapper for policy exchange and moves timeout constants to local scope

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +851 to +857
const PRE_SESSION_TIMEOUT: Duration = Duration::from_secs(60); // 60 seconds
#[cfg(feature = "policy_v2")]
let remote_policy = Box::pin(with_timeout(
PRE_SESSION_TIMEOUT,
pre_session_data_exchange(&mut transport),
))
.await??;
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constant PRE_SESSION_TIMEOUT is defined inside the function but before a feature gate. Consider moving it inside the #[cfg(feature = "policy_v2")] block since it's only used within that feature context, similar to how SPDM_TIMEOUT is placed inside its feature gate at line 994-995.

Suggested change
const PRE_SESSION_TIMEOUT: Duration = Duration::from_secs(60); // 60 seconds
#[cfg(feature = "policy_v2")]
let remote_policy = Box::pin(with_timeout(
PRE_SESSION_TIMEOUT,
pre_session_data_exchange(&mut transport),
))
.await??;
{
const PRE_SESSION_TIMEOUT: Duration = Duration::from_secs(60); // 60 seconds
let remote_policy = Box::pin(with_timeout(
PRE_SESSION_TIMEOUT,
pre_session_data_exchange(&mut transport),
))
.await??;
}

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

@IntelCaisui IntelCaisui Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remote_policy will be used later, connot warp it with {} false suggestion.
But later SPDM_TIMEOUT could adopt this style. Updated.

@IntelCaisui IntelCaisui force-pushed the 251121_FIX_POLICY_DOS branch from b778f36 to 02d3f1a Compare November 21, 2025 08:31
Wrap the pre-session v2 policy change with a timeout to prevent potential
    hang during pre migration.
@IntelCaisui IntelCaisui force-pushed the 251121_FIX_POLICY_DOS branch from 02d3f1a to 38d9ba6 Compare November 21, 2025 08:46
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.

1 participant