From 629787771b339ccd7f4f4598e30cf76161a81ebd Mon Sep 17 00:00:00 2001 From: "Dongjia \"toka\" Zhang" Date: Thu, 6 Mar 2025 16:12:05 +0100 Subject: [PATCH] Fix snapshot module (#3047) --- libafl_qemu/src/modules/usermode/snapshot.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libafl_qemu/src/modules/usermode/snapshot.rs b/libafl_qemu/src/modules/usermode/snapshot.rs index b291c905ce..cee748f1b0 100644 --- a/libafl_qemu/src/modules/usermode/snapshot.rs +++ b/libafl_qemu/src/modules/usermode/snapshot.rs @@ -423,9 +423,9 @@ impl SnapshotModule { // The heap has grown. so we want to drop those // we want to align the addresses before calling unmap // although it is very unlikely that the brk has an unaligned value - let new_page_boundary = (new_brk + ((SNAPSHOT_PAGE_MASK - 1) as GuestAddr)) + let new_page_boundary = (new_brk + ((SNAPSHOT_PAGE_SIZE - 1) as GuestAddr)) & (!(SNAPSHOT_PAGE_SIZE - 1) as GuestAddr); - let old_page_boundary = (self.brk + ((SNAPSHOT_PAGE_MASK - 1) as GuestAddr)) + let old_page_boundary = (self.brk + ((SNAPSHOT_PAGE_SIZE - 1) as GuestAddr)) & (!(SNAPSHOT_PAGE_SIZE - 1) as GuestAddr); if new_page_boundary != old_page_boundary {