Fix CI after CVE fixes (#5245)

* Fix CI after CVE fixes

Alas we can't run CI ahead of time so this fixes various minor build
issues from the merging of the recent CVE fixes. Note that I plan to
publish the advisories once CI issues are sorted out.

* Fix mmap/free of zero bytes
This commit is contained in:
Alex Crichton
2022-11-10 13:35:15 -06:00
committed by GitHub
parent f0fccbd18a
commit 92f6fe36cc
2 changed files with 8 additions and 2 deletions

View File

@@ -422,6 +422,7 @@ impl MemoryImageSlot {
} }
} }
#[cfg(feature = "pooling-allocator")]
pub(crate) fn dummy() -> MemoryImageSlot { pub(crate) fn dummy() -> MemoryImageSlot {
MemoryImageSlot { MemoryImageSlot {
base: 0, base: 0,
@@ -760,6 +761,12 @@ impl MemoryImageSlot {
/// Map anonymous zeroed memory across the whole slot, /// Map anonymous zeroed memory across the whole slot,
/// inaccessible. Used both during instantiate and during drop. /// inaccessible. Used both during instantiate and during drop.
fn reset_with_anon_memory(&mut self) -> Result<()> { fn reset_with_anon_memory(&mut self) -> Result<()> {
if self.static_size == 0 {
assert!(self.image.is_none());
assert_eq!(self.accessible, 0);
return Ok(());
}
unsafe { unsafe {
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(unix)] { if #[cfg(unix)] {

View File

@@ -10,7 +10,6 @@ use crate::Store;
use anyhow::Error; use anyhow::Error;
use anyhow::{bail, format_err, Result}; use anyhow::{bail, format_err, Result};
use std::convert::TryFrom; use std::convert::TryFrom;
use std::mem;
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use wasmtime_environ::{MemoryPlan, MemoryStyle, WASM32_MAX_PAGES, WASM64_MAX_PAGES}; use wasmtime_environ::{MemoryPlan, MemoryStyle, WASM32_MAX_PAGES, WASM64_MAX_PAGES};
@@ -768,7 +767,7 @@ impl Memory {
#[cfg(feature = "pooling-allocator")] #[cfg(feature = "pooling-allocator")]
pub fn unwrap_static_image(mut self) -> MemoryImageSlot { pub fn unwrap_static_image(mut self) -> MemoryImageSlot {
let mem = self.0.as_any_mut().downcast_mut::<StaticMemory>().unwrap(); let mem = self.0.as_any_mut().downcast_mut::<StaticMemory>().unwrap();
mem::replace(&mut mem.memory_image, MemoryImageSlot::dummy()) std::mem::replace(&mut mem.memory_image, MemoryImageSlot::dummy())
} }
/// If the [Memory] is a [SharedMemory], unwrap it and return a clone to /// If the [Memory] is a [SharedMemory], unwrap it and return a clone to