Skip to content

fix(guest-agent): avoid TDX Info quotes and bound attestation waits - #1659

Open
kingsleydon wants to merge 3 commits into
Dstack-TEE:nextfrom
kingsleydon:fix/guest-agent-info-quote-backlog
Open

kingsleydon wants to merge 3 commits into
Dstack-TEE:nextfrom
kingsleydon:fix/guest-agent-info-quote-backlog

Conversation

@kingsleydon

@kingsleydon kingsleydon commented Nov 27, 2026 •

Copy link
Copy Markdown

Problem

Legacy Info called attestation_for_info, which called Attestation::local() and generated a full quote just to read MRTD, RTMR0–3, and the event log. get_info · attestation_for_info · Attestation::local

AppStateInner::attest waited on an unbounded FIFO. Rocket kept running handlers after clients disconnected, so expired requests consumed quote capacity while live callers timed out behind them. Serial logs from two production TDX CVMs running dstack 0.6.5 showed roughly 2,600–2,950 Broken pipe messages per hour and node quote requests timed out. The backlog returned within minutes of a restart. AppStateInner::attest

Change

  • Detect TDREPORT support at startup. On TDX guests with /dev/tdx_guest, legacy Info reads TDREPORT and the event log outside the quote queue. Startup detection keeps the SEV-SNP configfs probe off the request path.
  • Bound queue admission with attest_queue_timeout_secs, which defaults to 15 seconds. An expired waiter leaves the queue and gets retryable HTTP 503. Each caller with an uncached identity uses the same deadline for identity initialization and quote admission.
  • A queue timeout leaves the retry cooldowns unset because no platform call ran. Identity decode failures and demo-cert failures still trigger their cooldowns, including demo key-generation failures.

Why 15 seconds

A 15-second wait accommodates roughly 15 queued one-second TDX quotes and leaves room for quote execution within the AntSeed prover's 20-second deadline and pig-tail's proposed 20-second per-RPC deadline. The TDX tcb_info path bypasses the quote queue. pig-tail PR #3

Compatibility

The tcb_info JSON fields, event log contents, and event ordering are identical. Non-TDX and configfs-only guests continue to use the existing attestation-backed Info path. With the default, those requests can wait up to 15 seconds for a quote slot, which exceeds the gateway's 10-second legacy Info timeout. Quotes on those paths are generally fast, though the gateway can time out first if the queue stays busy. Gateway legacy Info timeout

Tests

  • cargo test --locked -j 6 -p dstack-guest-agent -p dstack-guest-agent-simulator -p tdx-attest --all-features passed all 181 tests. The regressions cover the legacy TCB JSON during a held quote, expired and cancelled waiters, FIFO order, and concurrent identity callers receiving 503 within one wait bound.
  • cargo clippy --locked -j 6 -p dstack-guest-agent -p dstack-guest-agent-simulator -p tdx-attest -- -D warnings -D clippy::expect_used -D clippy::unwrap_used --allow unused_variables passed with the Rust workflow flags.
  • cargo fmt --check --all, reuse lint, and git diff origin/next...HEAD --check passed.

Not verified

Quote timing and concurrent TDREPORT and configfs or vsock quote generation on real TDX hardware.

🤖 Generated with Claude Code

Legacy Info minted a full TDX quote just to read MRTD, the RTMRs, and
the event log. Rocket kept running handlers after clients disconnected.
With an unbounded FIFO, abandoned requests consumed quote capacity
until live callers timed out too.

Read TDREPORT measurements and the event log for TDX Info outside the
quote queue. Bound attestation waits and return retryable HTTP 503 when
a wait expires. The 15-second default absorbs roughly 15 one-second
quotes while leaving time within AntSeed's 20-second deadline and the
proposed 20-second pig-tail deadline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Kingsley <10992364+kingsleydon@users.noreply.github.com>
@kingsleydon
kingsleydon force-pushed the fix/guest-agent-info-quote-backlog branch from 85a2911 to 58679d8 Compare November 27, 2026 06:35
Read MRTD and RTMR0-3 for legacy Info from the kernel's TSM measurement
sysfs (tdx_guest/measurements) instead of parsing TDREPORT offsets. The
kernel already decodes the report there, and the directory's presence is
enough to pick the local path, so the startup TEE probe and the TDREPORT
helpers are gone. Kernels without the interface fall back to the
attestation path as before. On a dstack 0.6.5 CVM the sysfs values match
the quote's and a read takes about 0.1 ms, also while a configfs quote is
in flight.

Bound the attestation queue wait with a constant 10-second timeout in
attest() only, matching the gateway's legacy Info timeout. A timed-out
wait returns HTTP 503 as an ordinary error, so the existing identity and
demo-cert throttles treat it like any other failure: congestion backs off
too. With the bound and the throttle in place every identity caller waits
at most one timeout, so identity() keeps its OnceCell and needs no
deadline of its own.

This drops the attest_queue_timeout_secs option, attest_until, the
AttestationQueueBusy type, the OnceLock/tokio::Mutex identity rewrite,
the demo-cert special case, and the unrelated message and comment edits.

Signed-off-by: Kevin Wang <wy721@qq.com>
@kvinwang

Copy link
Copy Markdown
Collaborator

The root cause of the backlog is that quotes go through the kernel's configfs path, which polls once a second, so each quote takes about 1 s although QGS answers in about 5 ms. #1660 switches tdx-attest to vsock first; this PR remains a safeguard on top of it.

The TEE simulator sets DCAP_TDX_RTMR_SYSFS_PATH to its own measurements
directory, which has rtmr0-3 but no mrtd. Following that override made
read_measurements() fail there, so legacy Info errored in the TDX
simulator, and in the SEV-SNP and Nitro simulators, where the directory
does not exist at all.

Read only the kernel's tdx_guest/measurements path. Simulated guests do
not have it and fall back to reading the measurements from a quote, as
before.

Signed-off-by: Kevin Wang <wy721@qq.com>

This branch has not been deployed

No deployments
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