From 2a5c248f32a6c333f91ebc9e78e7027128699a5b Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Wed, 16 Nov 2022 21:37:47 +0000 Subject: [PATCH] vm-migration: add two safety comments Signed-off-by: Wei Liu --- vm-migration/src/protocol.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vm-migration/src/protocol.rs b/vm-migration/src/protocol.rs index 765d04e31..9887813d0 100644 --- a/vm-migration/src/protocol.rs +++ b/vm-migration/src/protocol.rs @@ -257,6 +257,7 @@ impl MemoryRangeTable { length as usize / (std::mem::size_of::()), Default::default, ); + // SAFETY: the slice is construted with the correct arguments fd.read_exact(unsafe { std::slice::from_raw_parts_mut( data.as_ptr() as *mut MemoryRange as *mut u8, @@ -273,6 +274,7 @@ impl MemoryRangeTable { } pub fn write_to(&self, fd: &mut dyn Write) -> Result<(), MigratableError> { + // SAFETY: the slice is construted with the correct arguments fd.write_all(unsafe { std::slice::from_raw_parts( self.data.as_ptr() as *const MemoryRange as *const u8,