Update to rustix 0.26.2. (#3521)

This pulls in a fix for Android, where Android's seccomp policy on older
versions is to make `openat2` irrecoverably crash the process, so we have
to do a version check up front rather than relying on `ENOSYS` to
determine if `openat2` is supported.

And it pulls in the fix for the link errors when multiple versions of
rsix/rustix are linked in.

And it has updates for two crate renamings: rsix has been renamed to
rustix, and unsafe-io has been renamed to io-extras.
This commit is contained in:
Dan Gohman
2021-11-15 10:21:13 -08:00
committed by GitHub
parent 81f6228c57
commit ea0cb971fb
25 changed files with 136 additions and 137 deletions

View File

@@ -12,7 +12,7 @@ fn decommit(addr: *mut u8, len: usize, protect: bool) -> Result<()> {
}
// On Linux, this is enough to cause the kernel to initialize the pages to 0 on next access
rsix::io::madvise(addr as _, len, rsix::io::Advice::LinuxDontNeed)
rustix::io::madvise(addr as _, len, rustix::io::Advice::LinuxDontNeed)
.context("madvise failed to decommit: {}")?;
}

View File

@@ -33,7 +33,7 @@
use super::{InstancePool, MemoryPool};
use crate::instance::Instance;
use anyhow::{bail, Context, Result};
use rsix::io::{madvise, Advice};
use rustix::io::{madvise, Advice};
use std::thread;
use userfaultfd::{Event, FeatureFlags, IoctlFlags, Uffd, UffdBuilder};
use wasmtime_environ::{DefinedMemoryIndex, EntityRef, MemoryInitialization};

View File

@@ -10,15 +10,15 @@ fn decommit(addr: *mut u8, len: usize, protect: bool) -> Result<()> {
// The new mapping will be to the CoW zero page, so this effectively
// zeroes the pages.
unsafe {
rsix::io::mmap_anonymous(
rustix::io::mmap_anonymous(
addr as _,
len,
if protect {
rsix::io::ProtFlags::empty()
rustix::io::ProtFlags::empty()
} else {
rsix::io::ProtFlags::READ | rsix::io::ProtFlags::WRITE
rustix::io::ProtFlags::READ | rustix::io::ProtFlags::WRITE
},
rsix::io::MapFlags::PRIVATE | rsix::io::MapFlags::FIXED,
rustix::io::MapFlags::PRIVATE | rustix::io::MapFlags::FIXED,
)
.context("mmap failed to remap pages: {}")?;
}

View File

@@ -63,11 +63,11 @@ impl Mmap {
.len();
let len = usize::try_from(len).map_err(|_| anyhow!("file too large to map"))?;
let ptr = unsafe {
rsix::io::mmap(
rustix::io::mmap(
ptr::null_mut(),
len,
rsix::io::ProtFlags::READ,
rsix::io::MapFlags::PRIVATE,
rustix::io::ProtFlags::READ,
rustix::io::MapFlags::PRIVATE,
&file,
0,
)
@@ -170,11 +170,11 @@ impl Mmap {
Ok(if accessible_size == mapping_size {
// Allocate a single read-write region at once.
let ptr = unsafe {
rsix::io::mmap_anonymous(
rustix::io::mmap_anonymous(
ptr::null_mut(),
mapping_size,
rsix::io::ProtFlags::READ | rsix::io::ProtFlags::WRITE,
rsix::io::MapFlags::PRIVATE,
rustix::io::ProtFlags::READ | rustix::io::ProtFlags::WRITE,
rustix::io::MapFlags::PRIVATE,
)
.context(format!("mmap failed to allocate {:#x} bytes", mapping_size))?
};
@@ -187,11 +187,11 @@ impl Mmap {
} else {
// Reserve the mapping size.
let ptr = unsafe {
rsix::io::mmap_anonymous(
rustix::io::mmap_anonymous(
ptr::null_mut(),
mapping_size,
rsix::io::ProtFlags::empty(),
rsix::io::MapFlags::PRIVATE,
rustix::io::ProtFlags::empty(),
rustix::io::MapFlags::PRIVATE,
)
.context(format!("mmap failed to allocate {:#x} bytes", mapping_size))?
};
@@ -424,7 +424,7 @@ impl Drop for Mmap {
#[cfg(not(target_os = "windows"))]
fn drop(&mut self) {
if self.len != 0 {
unsafe { rsix::io::munmap(self.ptr as *mut std::ffi::c_void, self.len) }
unsafe { rustix::io::munmap(self.ptr as *mut std::ffi::c_void, self.len) }
.expect("munmap failed");
}
}

View File

@@ -294,21 +294,21 @@ pub fn lazy_per_thread_init() -> Result<(), Box<Trap>> {
let guard_size = page_size;
let alloc_size = guard_size + MIN_STACK_SIZE;
let ptr = rsix::io::mmap_anonymous(
let ptr = rustix::io::mmap_anonymous(
null_mut(),
alloc_size,
rsix::io::ProtFlags::empty(),
rsix::io::MapFlags::PRIVATE,
rustix::io::ProtFlags::empty(),
rustix::io::MapFlags::PRIVATE,
)
.map_err(|_| Box::new(Trap::oom()))?;
// Prepare the stack with readable/writable memory and then register it
// with `sigaltstack`.
let stack_ptr = (ptr as usize + guard_size) as *mut std::ffi::c_void;
rsix::io::mprotect(
rustix::io::mprotect(
stack_ptr,
MIN_STACK_SIZE,
rsix::io::MprotectFlags::READ | rsix::io::MprotectFlags::WRITE,
rustix::io::MprotectFlags::READ | rustix::io::MprotectFlags::WRITE,
)
.expect("mprotect to configure memory for sigaltstack failed");
let new_stack = libc::stack_t {
@@ -334,7 +334,7 @@ pub fn lazy_per_thread_init() -> Result<(), Box<Trap>> {
fn drop(&mut self) {
unsafe {
// Deallocate the stack memory.
let r = rsix::io::munmap(self.mmap_ptr, self.mmap_size);
let r = rustix::io::munmap(self.mmap_ptr, self.mmap_size);
debug_assert!(r.is_ok(), "munmap failed during thread shutdown");
}
}