From 1922cb0a650aaaed7cffa65008019564ea5f43ba Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Wed, 23 Aug 2023 09:13:08 +0100 Subject: [PATCH] qemu snapshot little update proposal. (#1431) * qemu snapshot little update proposal. * reeatablishing the TODO since the change does not do it at all but getting unrelated constant mask unrelated to mappings protection. --------- Co-authored-by: Andrea Fioraldi --- libafl_qemu/src/snapshot.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libafl_qemu/src/snapshot.rs b/libafl_qemu/src/snapshot.rs index deecf8775a..54a8ac4d4c 100644 --- a/libafl_qemu/src/snapshot.rs +++ b/libafl_qemu/src/snapshot.rs @@ -671,7 +671,7 @@ where h.access(a0 as GuestAddr, a1 as usize); } // mmap syscalls - _ => { + sys_const => { if result as GuestAddr == GuestAddr::MAX /* -1 */ { @@ -681,7 +681,7 @@ where // TODO handle huge pages #[cfg(any(cpu_target = "arm", cpu_target = "mips"))] - if i64::from(sys_num) == SYS_mmap2 { + if sys_const == SYS_mmap2 { if let Ok(prot) = MmapPerms::try_from(a2 as i32) { let h = hooks.match_helper_mut::().unwrap(); h.add_mapped(result as GuestAddr, a1 as usize, Some(prot)); @@ -689,24 +689,24 @@ where } #[cfg(not(cpu_target = "arm"))] - if i64::from(sys_num) == SYS_mmap { + if sys_const == SYS_mmap { if let Ok(prot) = MmapPerms::try_from(a2 as i32) { let h = hooks.match_helper_mut::().unwrap(); h.add_mapped(result as GuestAddr, a1 as usize, Some(prot)); } } - if i64::from(sys_num) == SYS_mremap { + if sys_const == SYS_mremap { let h = hooks.match_helper_mut::().unwrap(); + // TODO get the old permissions from the removed mapping h.remove_mapped(a0 as GuestAddr, a1 as usize); h.add_mapped(result as GuestAddr, a2 as usize, None); - // TODO get the old permissions from the removed mappin - } else if i64::from(sys_num) == SYS_mprotect { + } else if sys_const == SYS_mprotect { if let Ok(prot) = MmapPerms::try_from(a2 as i32) { let h = hooks.match_helper_mut::().unwrap(); h.add_mapped(a0 as GuestAddr, a1 as usize, Some(prot)); } - } else if i64::from(sys_num) == SYS_munmap { + } else if sys_const == SYS_munmap { let h = hooks.match_helper_mut::().unwrap(); if !h.accurate_unmap && !h.is_unmap_allowed(a0 as GuestAddr, a1 as usize) { h.remove_mapped(a0 as GuestAddr, a1 as usize);