From 145749d3f91eb3bc52615bd4ccaf39338c94129c Mon Sep 17 00:00:00 2001 From: "Yang, Longlong" Date: Thu, 7 Dec 2023 04:59:58 -0500 Subject: [PATCH] add memory address/size check for TD_INFO. fix #629 Signed-off-by: Yang, Longlong --- td-shim/src/metadata.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/td-shim/src/metadata.rs b/td-shim/src/metadata.rs index 160e6353..a00c707e 100644 --- a/td-shim/src/metadata.rs +++ b/td-shim/src/metadata.rs @@ -400,6 +400,11 @@ pub fn validate_sections(sections: &[TdxMetadataSection]) -> Result<(), TdxMetad td_info_start = section.data_offset; td_info_end = td_info_start + section.raw_data_size; } + + // MemoryAddress and MemoryDataSize shall be zero. + if section.memory_address != 0 || section.memory_data_size != 0 { + return Err(TdxMetadataError::InvalidSection); + } } _ => {