From 4be8caae219cab84c33bd7798b358b438c6a1fb9 Mon Sep 17 00:00:00 2001 From: m-mueller678 Date: Wed, 19 Mar 2025 15:55:19 +0100 Subject: [PATCH] fix high guard page --- src/mmap_stack_restore_guard.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mmap_stack_restore_guard.rs b/src/mmap_stack_restore_guard.rs index ba378ed..1e021c2 100644 --- a/src/mmap_stack_restore_guard.rs +++ b/src/mmap_stack_restore_guard.rs @@ -44,19 +44,19 @@ impl StackRestoreGuard { size_with_guard, old_stack_limit: get_stack_limit(), }; - // We leave a guard page without read/write access in our allocation. + // We leave two guard pages without read/write access in our allocation. // There is one guard page below the stack and another above it. let above_guard_page = new_stack.add(page_size); #[cfg(not(target_os = "openbsd"))] let result = libc::mprotect( above_guard_page, - size_with_guard - page_size, + size_with_guard - 2 * page_size, libc::PROT_READ | libc::PROT_WRITE, ); #[cfg(target_os = "openbsd")] let result = if libc::mmap( above_guard_page, - size_with_guard - page_size, + size_with_guard - 2 * page_size, libc::PROT_READ | libc::PROT_WRITE, libc::MAP_FIXED | libc::MAP_PRIVATE | libc::MAP_ANON | libc::MAP_STACK, -1,