unix: unsafe-wrap install_main_guard_default · model-checking/verify-rust-std@aedc16c
@@ -419,6 +419,7 @@ mod imp {
419419Some(stackaddr - page_size..stackaddr)
420420}
421421422+#[forbid(unsafe_op_in_unsafe_fn)]
422423unsafe fn install_main_guard_default(page_size: usize) -> Option<Range<usize>> {
423424// Reallocate the last page of the stack.
424425// This ensures SIGBUS will be raised on
@@ -429,19 +430,21 @@ mod imp {
429430// read/write permissions and only then mprotect() it to
430431// no permissions at all. See issue #50313.
431432let stackptr = stack_start_aligned(page_size)?;
432-let result = mmap64(
433- stackptr,
434- page_size,
435-PROT_READ | PROT_WRITE,
436-MAP_PRIVATE | MAP_ANON | MAP_FIXED,
437- -1,
438-0,
439-);
433+let result = unsafe {
434+mmap64(
435+ stackptr,
436+ page_size,
437+PROT_READ | PROT_WRITE,
438+MAP_PRIVATE | MAP_ANON | MAP_FIXED,
439+ -1,
440+0,
441+)
442+};
440443if result != stackptr || result == MAP_FAILED {
441444panic!("failed to allocate a guard page: {}", io::Error::last_os_error());
442445}
443446444-let result = mprotect(stackptr, page_size, PROT_NONE);
447+let result = unsafe { mprotect(stackptr, page_size, PROT_NONE) };
445448if result != 0 {
446449panic!("failed to protect the guard page: {}", io::Error::last_os_error());
447450}