Skip to content

Commit

Permalink
tee-info-hash-tool: update the metadata check when type is TD_INFO
Browse files Browse the repository at this point in the history
Signed-off-by: xiaoyuxlu <[email protected]>
  • Loading branch information
xiaoyuxlu committed Dec 13, 2024
1 parent c3dc451 commit 5b1cf62
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion td-shim-tools/src/tee_info_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,12 @@ impl TdInfoStruct {
panic!("Memory address must be 4K aligned!\n");
}

if sec.memory_data_size < sec.raw_data_size as u64 {
// Align with the implementation at:
// https://github.com/confidential-containers/td-shim/blob/3ebd63b8f213aff83f4df8901709a58a219790c4/td-shim-interface/src/metadata.rs#L405
if (sec.r#type != TDX_METADATA_SECTION_TYPE_TD_INFO)
&& (sec.memory_address != 0 || sec.memory_data_size != 0)
&& sec.memory_data_size < sec.raw_data_size as u64
{
panic!("Memory data size must exceed or equal the raw data size!\n");
}

Expand Down

0 comments on commit 5b1cf62

Please sign in to comment.