pub struct UserPtrRO<T>where
T: Copy,{
addr: usize,
_ty: PhantomData<T>,
}Expand description
A one-time, read-only pointer to a user-space object of type T.
This struct allows the kernel to read from user-space while ensuring safe access patterns. It prevents TOCTOU (Time-of-Check to Time-of-Use) attacks by taking ownership of the pointer during operations.
§Type Parameter
T: The type of the data being accessed. Must implementCopy.
Fields§
§addr: usize§_ty: PhantomData<T>Implementations§
Source§impl<T> UserPtrRO<T>where
T: Copy,
impl<T> UserPtrRO<T>where
T: Copy,
Sourcepub fn new(addr: usize) -> Self
pub fn new(addr: usize) -> Self
Creates a new UserPtrRO instance with the given user-space address.
Sourcepub fn get(self) -> Result<T, KernelError>
pub fn get(self) -> Result<T, KernelError>
Reads a value of type T from the user-space address.
Takes ownership of self to prevent TOCTOU attacks.
Returns Ok(T) if successful, otherwise
Err(KernelError::BadAddress).