Skip to content

Conversation

@kvinwang
Copy link
Collaborator

@kvinwang kvinwang commented Jan 26, 2026

Summary

  • Rewrite tdx-attest in pure Rust, eliminating C code dependency
  • Remove tdx-attest-sys dependency from tdx-attest
  • Support both glibc and musl targets natively

Changes

  • tdx-attest/src/linux.rs: Complete rewrite with:

    • ConfigFS quote generation (Linux 6.7+ TSM interface)
    • VSock/QGS quote generation (legacy systems)
    • sysfs RTMR extension (newer kernels)
    • ioctl RTMR extension via /dev/tdx_guest (legacy)
    • Platform-specific ioctl request types (glibc vs musl)
    • Separate availability detection from execution errors
  • tdx-attest/src/dummy.rs: Simplified stub implementation

  • tdx-attest/Cargo.toml: Replace tdx-attest-sys with libc + vsock

  • tdx-attest/examples/test_tdx.rs: Test program with dcap-qvl verification

API

The public API:

  • get_quote(report_data: &[u8; 64]) -> Result<Vec<u8>>
  • get_report(report_data: &[u8; 64]) -> Result<TdxReport>
  • extend_rtmr(index: u32, event_type: u32, digest: [u8; 48]) -> Result<()>

Test Results

dstack 0.6.0 (kernel 6.17.6-dstack)

Function Method Result
get_report ioctl
get_quote ConfigFS
Quote verification dcap-qvl ✓ (UpToDate)
extend_rtmr sysfs

dstack 0.5.4 (kernel 6.9.0-dstack)

Function Method Result
get_report ioctl
get_quote VSock/QGS
Quote verification dcap-qvl ✓ (UpToDate)
extend_rtmr ioctl

Build Verification

  • Build with glibc: cargo build -p tdx-attest
  • Build with musl: cargo build --target x86_64-unknown-linux-musl -p tdx-attest
  • Build dependent crates: dstack-attest, dstack-util
  • Run clippy: cargo clippy -p tdx-attest

@kvinwang kvinwang force-pushed the musl-tdx-support branch 3 times, most recently from 5f3c006 to 7f82973 Compare January 26, 2026 15:07
@kvinwang kvinwang changed the title feat(tdx-attest): Add MUSL libc support for TDX attestation feat(tdx-attest): Rewrite TDX attestation in pure Rust Jan 26, 2026
@kvinwang kvinwang force-pushed the musl-tdx-support branch 4 times, most recently from 0f19412 to aab4fd4 Compare January 27, 2026 00:44
@kvinwang kvinwang force-pushed the musl-tdx-support branch 7 times, most recently from fb83c10 to d26b0f0 Compare January 27, 2026 01:47
@kvinwang kvinwang enabled auto-merge (squash) January 27, 2026 01:48
Enable building with x86_64-unknown-linux-musl target by:

1. Vendoring minimal Linux kernel headers that are missing from MUSL:
   - linux/vm_sockets.h: vsock address family and sockaddr_vm struct
   - linux/types.h: kernel type aliases (__u8, __u32, __u64, etc.)
   - linux/ioctl.h: redirect to MUSL's sys/ioctl.h

2. Updating cfg conditions to include MUSL (target_env = "musl")
   alongside glibc (target_env = "gnu")

3. Modifying build.rs to prioritize vendored headers via include path

This allows building statically-linked TDX attestation binaries using
MUSL, which is useful for containerized deployments and systems without
glibc.

Tested: cargo build --target x86_64-unknown-linux-musl -p tdx-attest
Implement TDX attestation without C library dependencies:

- get_quote: ConfigFS (Linux 6.7+) → VSock/QGS fallback
- extend_rtmr: sysfs → ioctl fallback
- get_report: ioctl via /dev/tdx_guest
- get_supported_att_key_ids: returns Intel TDQE UUID

Key changes:
- Add vsock crate for QGS protocol communication
- Probe availability before execution (separate NotSupported from errors)
- Include original error context in error messages
- Support both new dstack OS (ConfigFS/sysfs) and legacy 0.5.4 (VSock/ioctl)

Tested on:
- New dstack OS: ConfigFS for quote, sysfs for extend_rtmr
- dstack 0.5.4: VSock for quote, ioctl for extend_rtmr
@kvinwang kvinwang merged commit aca96b6 into master Jan 27, 2026
11 checks passed
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