File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -205,6 +205,9 @@ where
205205 assert ! ( size_of:: <StateShMemContent >( ) + len <= self . shmem. len( ) ) ;
206206
207207 let shmem_content = self . content_mut ( ) ;
208+ // # Safety
209+ // `buf` is large enough to hold `[u8; 16]` and is properly aligned (u8 alignment is 1),
210+ // and `buf_len` points to a valid field in shared memory.
208211 unsafe {
209212 ptr:: write_volatile (
210213 shmem_content. buf . as_mut_ptr ( ) . cast :: < [ u8 ; 16 ] > ( ) ,
@@ -220,10 +223,14 @@ where
220223 let len = EXITING_MAGIC . len ( ) ;
221224 assert ! ( size_of:: <StateShMemContent >( ) + len <= self . shmem. len( ) ) ;
222225 let content = self . content ( ) ;
226+ // # Safety
227+ // `content.buf_len` points to a valid field in the shared memory map.
223228 let buf_len = unsafe { read_volatile ( & raw const content. buf_len ) } ;
224229 if buf_len != len {
225230 return false ;
226231 }
232+ // # Safety
233+ // `content.buf` is checked above to contain at least 16 bytes and is properly aligned (u8 alignment is 1).
227234 let magic = unsafe { read_volatile ( content. buf . as_ptr ( ) . cast :: < [ u8 ; 16 ] > ( ) ) } ;
228235 magic == * EXITING_MAGIC
229236 }
You can’t perform that action at this time.
0 commit comments