fix(tpm): treat a full event log as a successful measurement

The TCG2 specification says HashLogExtendEvent returns VOLUME_FULL when
the PCR was extended but the event log had no room for the event. This
was treated as a failure, which aborted loading the configuration and
booting Edera. Log a warning and continue instead.
This commit is contained in:
alex authored and Alex Zenla committed 2026-09-26 20:52:15 -07:00
1 parent 3490ec24f2
commit 98f1a2c8c5
1 file changed
+23 -6
+23 -6
View File
@@ -1,8 +1,10 @@
use anyhow::{Context, Result};
use log::warn;
use uefi::ResultExt;
use uefi::boot::ScopedProtocol;
use uefi::proto::tcg::PcrIndex;
use uefi::proto::tcg::v2::{PcrEventInputs, Tcg};
use uefi_raw::Status;
use uefi_raw::protocol::tcg::EventType;
use uefi_raw::protocol::tcg::v2::{Tcg2HashLogExtendEventFlags, Tcg2Protocol, Tcg2Version};
@@ -121,18 +123,33 @@ impl PlatformTpm {
};
// Encode the description as UTF-8.
let description = description.as_bytes().to_vec();
let encoded_description = description.as_bytes().to_vec();
// Construct an event input for the TPM.
let event = PcrEventInputs::new_in_box(pcr_index, EventType::IPL, &description)
let event = PcrEventInputs::new_in_box(pcr_index, EventType::IPL, &encoded_description)
.discard_errdata()
.context("unable to construct pcr event inputs")?;
// Log the event into the TPM.
handle
.protocol()
.hash_log_extend_event(Tcg2HashLogExtendEventFlags::empty(), buffer, &event)
.context("unable to log event to tpm")?;
let result = handle.protocol().hash_log_extend_event(
Tcg2HashLogExtendEventFlags::empty(),
buffer,
&event,
);
// A full event log means the PCR was extended, but the event could not be logged.
// The measurement still happened, so this should not prevent booting.
if let Err(ref error) = result
&& error.status() == Status::VOLUME_FULL
{
warn!(
"tpm event log is full, unable to log event: {}",
description
);
return Ok(());
}
result.context("unable to log event to tpm")?;
Ok(())
}
}