Skip to content

Commit

Permalink
tdx-attester: update TD platform detection
Browse files Browse the repository at this point in the history
The attester crate pulls in DCAP 1.20 which only supports
/dev/tdx_guest ioctls so the two other (legacy) character devices
can be dropped.

However, this triggers another issue: we can have /dev/tdx_guest
ioctls (e.g., the RTMR extend) that are not part of Linux upstream
so the recently added runtime_measurement_extend_available() won't
work anymore. This change tries to mitigate that (for the time being)
by making the simplification that "if TSM reports, no RTMRs".

Signed-off-by: Mikko Ylinen <[email protected]>
  • Loading branch information
mythi authored and Xynnn007 committed Jun 7, 2024
1 parent 1ae345c commit 4132954
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions attestation-agent/attester/src/tdx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ const CCEL_PATH: &str = "/sys/firmware/acpi/tables/data/CCEL";
const RUNTIME_MEASUREMENT_RTMR_INDEX: u64 = 2;

pub fn detect_platform() -> bool {
TsmReportPath::new(TsmReportProvider::Tdx).is_ok() || tdx_getquote_ioctl_is_available()
}

fn tdx_getquote_ioctl_is_available() -> bool {
Path::new("/dev/tdx-attest").exists()
|| Path::new("/dev/tdx-guest").exists()
|| Path::new("/dev/tdx_guest").exists()
TsmReportPath::new(TsmReportProvider::Tdx).is_ok() || Path::new("/dev/tdx_guest").exists()
}

fn get_quote_ioctl(report_data: &Vec<u8>) -> Result<Vec<u8>> {
Expand All @@ -49,9 +43,11 @@ fn get_quote_ioctl(report_data: &Vec<u8>) -> Result<Vec<u8>> {
}

// Return true if the TD environment can extend runtime measurement,
// else false.
// else false. The best guess at the moment is that if "TSM reports"
// is available, the TD runs Linux upstream kernel and is _currently_
// not able to do it.
fn runtime_measurement_extend_available() -> bool {
if Path::new("/dev/tdx_guest").exists() || Path::new("/sys/kernel/config/tsm/report").exists() {
if Path::new("/sys/kernel/config/tsm/report").exists() {
return false;
}

Expand Down

0 comments on commit 4132954

Please sign in to comment.