diff --git a/crates/libafl_qemu/src/modules/usermode/snapshot.rs b/crates/libafl_qemu/src/modules/usermode/snapshot.rs index d96c5b2d163..72ab758c561 100644 --- a/crates/libafl_qemu/src/modules/usermode/snapshot.rs +++ b/crates/libafl_qemu/src/modules/usermode/snapshot.rs @@ -238,14 +238,15 @@ impl SnapshotModule { self.initial_brk = qemu.get_initial_brk(); self.mmap_start = qemu.get_mmap_start(); self.pages.clear(); + for acc in &mut self.accesses { + unsafe { (*acc.get()).clear() }; + } for map in qemu.mappings() { - println!("mapping: {map:?}"); + log::debug!("mapping: {map:}"); let mut addr = map.start(); while addr < map.end() { - let zero = self.interval_filter.to_zero(addr); - let skip = self.interval_filter.to_skip(addr); - if let Some(range) = zero.or(skip) { + if let Some(range) = self.interval_filter.to_skip(addr) { addr = range.end; continue; } @@ -255,7 +256,7 @@ impl SnapshotModule { private: map.is_priv(), data: None, }; - if map.flags().readable() { + if map.flags().readable() && self.interval_filter.to_zero(addr).is_none() { // TODO not just for R pages unsafe { info.data = Some(Box::new(core::mem::zeroed())); @@ -478,7 +479,7 @@ impl SnapshotModule { for acc in &mut self.accesses { unsafe { &mut (*acc.get()) }.dirty.retain(|page| { if let Some(info) = self.pages.get_mut(page) { - if self.interval_filter.to_skip(*page as u64).is_some() { + if self.interval_filter.to_zero(*page as u64).is_some() { if !Self::modify_mapping(qemu, new_maps, *page) { return true; // Restore later } @@ -523,7 +524,7 @@ impl SnapshotModule { } } - if self.interval_filter.to_skip(*page as u64).is_some() { + if self.interval_filter.to_zero(*page as u64).is_some() { unsafe { qemu.write_mem_unchecked(*page, &SNAPSHOT_PAGE_ZEROES) }; } else if let Some(info) = self.pages.get_mut(page) { // TODO avoid duplicated memcpy