Skip to main content

Module userslice

Module userslice 

Source
Expand description

Userspace pointer validation for Strat9-OS.

The UserSlice pattern (inspired by RedoxOS usercopy.rs) ensures the kernel never dereferences a raw userspace pointer without first checking:

  1. Range: The entire region lies in the user half (< USER_SPACE_END)
  2. Overflow: base + len doesn’t wrap around
  3. Mapping: Every page in the region is present in the active page tables with the requested permissions (read or write)

After validation, UserSlice provides safe copy operations that transfer data between userspace and kernel buffers.

§Example

// In a syscall handler:
let user_buf = UserSliceRead::new(buf_ptr, buf_len)?;
let mut kernel_buf = [0u8; 256];
let n = user_buf.copy_to(&mut kernel_buf)?;

Structs§

UserSliceRead
A validated read-only reference to a user-space memory region.
UserSliceReadWrite
A validated read-write reference to a user-space memory region.
UserSliceWrite
A validated writable reference to a user-space memory region.

Enums§

UserSliceError
Errors that can occur when constructing or using a UserSlice.