Skip to content

Commit 9a52970

Browse files
m-mueller678nagisa
authored andcommitted
fix high guard page
1 parent 5c4a33f commit 9a52970

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/mmap_stack_restore_guard.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ impl StackRestoreGuard {
4444
size_with_guard,
4545
old_stack_limit: get_stack_limit(),
4646
};
47-
// We leave a guard page without read/write access in our allocation.
47+
// We leave two guard pages without read/write access in our allocation.
4848
// There is one guard page below the stack and another above it.
4949
let above_guard_page = new_stack.add(page_size);
5050
#[cfg(not(target_os = "openbsd"))]
5151
let result = libc::mprotect(
5252
above_guard_page,
53-
size_with_guard - page_size,
53+
size_with_guard - 2 * page_size,
5454
libc::PROT_READ | libc::PROT_WRITE,
5555
);
5656
#[cfg(target_os = "openbsd")]
5757
let result = if libc::mmap(
5858
above_guard_page,
59-
size_with_guard - page_size,
59+
size_with_guard - 2 * page_size,
6060
libc::PROT_READ | libc::PROT_WRITE,
6161
libc::MAP_FIXED | libc::MAP_PRIVATE | libc::MAP_ANON | libc::MAP_STACK,
6262
-1,

0 commit comments

Comments
 (0)