Skip to content

Commit 5a4adba

Browse files
Merge #395
395: [PLAT-896] Verify fifo descriptor pointers r=mzohreva a=raoulstrackx When processing `FifoDescriptor` to turn it into a `ipc_queue`, the offset point isn't verified correctly. Co-authored-by: Raoul Strackx <[email protected]>
2 parents 998c34d + a892f67 commit 5a4adba

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ipc-queue/src/fifo.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl<T: Transmittable> Fifo<T> {
9494
"Fifo len should be a power of two"
9595
);
9696
#[cfg(target_env = "sgx")] {
97-
use std::os::fortanix_sgx::usercalls::alloc::User;
97+
use std::os::fortanix_sgx::usercalls::alloc::{User, UserRef};
9898

9999
// `fortanix_sgx_abi::WithId` is not `Copy` because it contains an `AtomicU64`.
100100
// This type has the same memory layout but is `Copy` and can be marked as
@@ -112,9 +112,15 @@ impl<T: Transmittable> Fifo<T> {
112112
let _: [u8; size_of::<fortanix_sgx_abi::WithId<()>>()] = [0u8; size_of::<WithId<()>>()];
113113
}
114114

115+
#[repr(transparent)]
116+
#[derive(Copy, Clone)]
117+
struct WrapUsize(usize);
118+
unsafe impl UserSafeSized for WrapUsize{}
119+
115120
// check pointers are outside enclave range, etc.
116121
let data = User::<[WithId<T>]>::from_raw_parts(descriptor.data as _, descriptor.len);
117122
mem::forget(data);
123+
UserRef::from_ptr(descriptor.offsets as *const WrapUsize);
118124
}
119125
let data_slice = std::slice::from_raw_parts(descriptor.data, descriptor.len);
120126
Self {

0 commit comments

Comments
 (0)