From cbcbf635ab10614ac3d07902730562cc698d83b2 Mon Sep 17 00:00:00 2001 From: Muminul Islam Date: Thu, 4 Jan 2024 15:39:52 -0800 Subject: [PATCH] hypervisor: use right size of host_data Use right and exact size 32 bytes for host data field for completing the isolated import. This way OOB can be avoided during a function call. Signed-off-by: Muminul Islam --- hypervisor/src/mshv/mod.rs | 4 ++-- hypervisor/src/vm.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index 5cc063e8b..514e000ba 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -1814,7 +1814,7 @@ impl vm::Vm for MshvVm { fn complete_isolated_import( &self, snp_id_block: IGVM_VHS_SNP_ID_BLOCK, - host_data: &[u8], + host_data: [u8; 32], id_block_enabled: u8, ) -> vm::Result<()> { let mut auth_info = hv_snp_id_auth_info { @@ -1847,7 +1847,7 @@ impl vm::Vm for MshvVm { policy: get_default_snp_guest_policy(), }, id_auth_info: auth_info, - host_data: host_data[0..32].try_into().unwrap(), + host_data, id_block_enabled, author_key_enabled: 0, }, diff --git a/hypervisor/src/vm.rs b/hypervisor/src/vm.rs index ebe504ede..cafced0a1 100644 --- a/hypervisor/src/vm.rs +++ b/hypervisor/src/vm.rs @@ -385,7 +385,7 @@ pub trait Vm: Send + Sync + Any { fn complete_isolated_import( &self, _snp_id_block: IGVM_VHS_SNP_ID_BLOCK, - _host_data: &[u8], + _host_data: [u8; 32], _id_block_enabled: u8, ) -> Result<()> { unimplemented!()