pub struct UserPtrWO<T>where
T: Copy,{
addr: usize,
_ty: PhantomData<T>,
}Expand description
A one-time, write-only pointer to a user-space object of type T.
This struct allows the kernel to write to 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> UserPtrWO<T>where
T: Copy,
impl<T> UserPtrWO<T>where
T: Copy,
Sourcepub fn new(addr: usize) -> Self
pub fn new(addr: usize) -> Self
Creates a new UserPtrWO instance with the given user-space address.
Sourcepub fn put(self, other: T) -> Result<usize, KernelError>
pub fn put(self, other: T) -> Result<usize, KernelError>
Writes a value of type T to the user-space address.
Takes ownership of self to prevent TOCTOU attacks.
Returns Ok(usize) indicating the number of bytes written, or
Err(KernelError::BadAddress) on failure.