1
0
Fork 0
forked from koniifer/ableos

Forbid store

This commit is contained in:
Erin 2023-08-09 02:57:25 +02:00
parent 06d66289bc
commit 3ac80a2e3d

View file

@ -98,6 +98,10 @@ impl<'p, PfH: HandlePageFault> SoftPagedMem<'p, PfH> {
action: fn(*mut u8, *mut u8, usize), action: fn(*mut u8, *mut u8, usize),
) -> Result<(), u64> { ) -> Result<(), u64> {
let (src, len) = if src < self.program.len() as _ { let (src, len) = if src < self.program.len() as _ {
if reason != MemoryAccessReason::Load {
return Err(src);
}
let to_copy = len.clamp(0, self.program.len().saturating_sub(src as _)); let to_copy = len.clamp(0, self.program.len().saturating_sub(src as _));
action( action(
unsafe { self.program.as_ptr().add(src as _).cast_mut() }, unsafe { self.program.as_ptr().add(src as _).cast_mut() },