From afdcee9bd641858419963e5772ea014724da10f3 Mon Sep 17 00:00:00 2001 From: Erin Date: Wed, 9 Aug 2023 02:57:25 +0200 Subject: [PATCH] Forbid store --- hbvm/src/softpaging/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hbvm/src/softpaging/mod.rs b/hbvm/src/softpaging/mod.rs index 3db62486..bf35ff13 100644 --- a/hbvm/src/softpaging/mod.rs +++ b/hbvm/src/softpaging/mod.rs @@ -98,6 +98,10 @@ impl<'p, PfH: HandlePageFault> SoftPagedMem<'p, PfH> { action: fn(*mut u8, *mut u8, usize), ) -> Result<(), u64> { 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 _)); action( unsafe { self.program.as_ptr().add(src as _).cast_mut() },