diff --git a/Cargo.lock b/Cargo.lock index b347a8b9fddd..f3fef848788b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -665,7 +665,7 @@ dependencies = [ "target-lexicon", "thiserror", "toml", - "wasmparser 0.121.0", + "wasmparser", "wat", ] @@ -844,7 +844,7 @@ dependencies = [ "serde_derive", "smallvec", "target-lexicon", - "wasmparser 0.121.0", + "wasmparser", "wasmtime-types", "wat", ] @@ -2632,7 +2632,7 @@ version = "0.0.0" dependencies = [ "cargo_metadata", "heck", - "wit-component 0.20.1", + "wit-component 0.21.0", ] [[package]] @@ -2945,7 +2945,7 @@ name = "verify-component-adapter" version = "19.0.0" dependencies = [ "anyhow", - "wasmparser 0.121.0", + "wasmparser", "wat", ] @@ -3052,7 +3052,7 @@ dependencies = [ "byte-array-literals", "object", "wasi", - "wasm-encoder 0.41.0", + "wasm-encoder", "wit-bindgen", ] @@ -3129,27 +3129,18 @@ checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "wasm-encoder" -version = "0.38.1" +version = "0.41.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad2b51884de9c7f4fe2fd1043fccb8dcad4b1e29558146ee57a144d15779f3f" -dependencies = [ - "leb128", -] - -[[package]] -name = "wasm-encoder" -version = "0.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e09bca7d6388637d27fb5edbeab11f56bfabcef8743c55ae34370e1e5030a071" +checksum = "972f97a5d8318f908dded23594188a90bcd09365986b1163e66d70170e5287ae" dependencies = [ "leb128", ] [[package]] name = "wasm-metadata" -version = "0.10.17" +version = "0.10.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c853d3809fc9fccf3bc0ad63f4f51d8eefad0bacf88f957aa991c1d9b88b016e" +checksum = "18ebaa7bd0f9e7a5e5dd29b9a998acf21c4abed74265524dd7e85934597bfb10" dependencies = [ "anyhow", "indexmap 2.0.0", @@ -3157,35 +3148,36 @@ dependencies = [ "serde_derive", "serde_json", "spdx", - "wasm-encoder 0.41.0", - "wasmparser 0.121.0", + "wasm-encoder", + "wasmparser", ] [[package]] name = "wasm-mutate" -version = "0.2.46" +version = "0.2.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e89f070944fe6b516669e81589f63ddd90fe8f94f33b119908ebdf22593cbf" +checksum = "66190ebefee2459923201c7683489eda894e703625b0c91324b1186b830410e0" dependencies = [ "egg", "log", "rand", "thiserror", - "wasm-encoder 0.41.0", - "wasmparser 0.121.0", + "wasm-encoder", + "wasmparser", ] [[package]] name = "wasm-smith" -version = "0.15.1" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea4e4f4234958299a110ccc01b4ad396cece58a02fced8771b319c56d596f6d" +checksum = "9411792ad7c3f356ec2b31685d6553e4e8c20ed9efa192c24ab7f7560c290598" dependencies = [ + "anyhow", "arbitrary", "flagset", "indexmap 2.0.0", "leb128", - "wasm-encoder 0.41.0", + "wasm-encoder", ] [[package]] @@ -3230,19 +3222,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.118.1" +version = "0.121.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ee9723b928e735d53000dec9eae7b07a60e490c85ab54abb66659fc61bfcd9" -dependencies = [ - "indexmap 2.0.0", - "semver", -] - -[[package]] -name = "wasmparser" -version = "0.121.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953cf6a7606ab31382cb1caa5ae403e77ba70c7f8e12eeda167e7040d42bfda8" +checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ "bitflags 2.4.1", "indexmap 2.0.0", @@ -3260,12 +3242,12 @@ dependencies = [ [[package]] name = "wasmprinter" -version = "0.2.78" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e32c13c59fdc64d3f6998a1d52eb1d362b6904a88b754190ccb85661ad577a" +checksum = "60e73986a6b7fdfedb7c5bf9e7eb71135486507c8fbc4c0c42cffcb6532988b7" dependencies = [ "anyhow", - "wasmparser 0.121.0", + "wasmparser", ] [[package]] @@ -3296,8 +3278,8 @@ dependencies = [ "target-lexicon", "tempfile", "wasi-cap-std-sync", - "wasm-encoder 0.41.0", - "wasmparser 0.121.0", + "wasm-encoder", + "wasmparser", "wasmtime-cache", "wasmtime-component-macro", "wasmtime-component-util", @@ -3429,7 +3411,7 @@ dependencies = [ "tokio", "tracing", "walkdir", - "wasmparser 0.121.0", + "wasmparser", "wasmtime", "wasmtime-cache", "wasmtime-cli-flags", @@ -3443,10 +3425,10 @@ dependencies = [ "wasmtime-wasi-nn", "wasmtime-wasi-threads", "wasmtime-wast", - "wast 70.0.2", + "wast 71.0.1", "wat", "windows-sys 0.52.0", - "wit-component 0.20.1", + "wit-component 0.21.0", ] [[package]] @@ -3475,7 +3457,7 @@ dependencies = [ "wasmtime", "wasmtime-component-util", "wasmtime-wit-bindgen", - "wit-parser", + "wit-parser 0.14.0", ] [[package]] @@ -3499,7 +3481,7 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.121.0", + "wasmparser", "wasmtime-cranelift-shared", "wasmtime-environ", "wasmtime-versioned-export-macros", @@ -3538,8 +3520,8 @@ dependencies = [ "serde_derive", "target-lexicon", "thiserror", - "wasm-encoder 0.41.0", - "wasmparser 0.121.0", + "wasm-encoder", + "wasmparser", "wasmprinter", "wasmtime-component-util", "wasmtime-types", @@ -3554,7 +3536,7 @@ dependencies = [ "component-fuzz-util", "env_logger", "libfuzzer-sys", - "wasmparser 0.121.0", + "wasmparser", "wasmprinter", "wasmtime-environ", "wat", @@ -3611,7 +3593,7 @@ dependencies = [ "rand", "smallvec", "target-lexicon", - "wasmparser 0.121.0", + "wasmparser", "wasmtime", "wasmtime-fuzzing", ] @@ -3631,12 +3613,12 @@ dependencies = [ "target-lexicon", "tempfile", "v8", - "wasm-encoder 0.41.0", + "wasm-encoder", "wasm-mutate", "wasm-smith", "wasm-spec-interpreter", "wasmi", - "wasmparser 0.121.0", + "wasmparser", "wasmprinter", "wasmtime", "wasmtime-wast", @@ -3683,7 +3665,7 @@ dependencies = [ "rand", "rustix", "sptr", - "wasm-encoder 0.41.0", + "wasm-encoder", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-fiber", @@ -3701,7 +3683,7 @@ dependencies = [ "serde", "serde_derive", "thiserror", - "wasmparser 0.121.0", + "wasmparser", ] [[package]] @@ -3812,7 +3794,7 @@ dependencies = [ "anyhow", "log", "wasmtime", - "wast 70.0.2", + "wast 71.0.1", ] [[package]] @@ -3824,7 +3806,7 @@ dependencies = [ "gimli", "object", "target-lexicon", - "wasmparser 0.121.0", + "wasmparser", "wasmtime-cranelift-shared", "wasmtime-environ", "winch-codegen", @@ -3837,7 +3819,7 @@ dependencies = [ "anyhow", "heck", "indexmap 2.0.0", - "wit-parser", + "wit-parser 0.14.0", ] [[package]] @@ -3855,24 +3837,24 @@ dependencies = [ [[package]] name = "wast" -version = "70.0.2" +version = "71.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3d5061300042ff5065123dae1e27d00c03f567d34a2937c8472255148a216dc" +checksum = "647c3ac4354da32688537e8fc4d2fe6c578df51896298cb64727d98088a1fd26" dependencies = [ "bumpalo", "leb128", "memchr", "unicode-width", - "wasm-encoder 0.41.0", + "wasm-encoder", ] [[package]] name = "wat" -version = "1.0.85" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afd7357b6cc46d46a2509c43dcb1dd4131dafbf4e75562d87017b5a05ffad2d6" +checksum = "b69c36f634411568a2c6d24828b674961e37ea03340fe1d605c337ed8162d901" dependencies = [ - "wast 70.0.2", + "wast 71.0.1", ] [[package]] @@ -3997,7 +3979,7 @@ dependencies = [ "regalloc2", "smallvec", "target-lexicon", - "wasmparser 0.121.0", + "wasmparser", "wasmtime-environ", ] @@ -4013,7 +3995,7 @@ dependencies = [ "similar", "target-lexicon", "toml", - "wasmparser 0.121.0", + "wasmparser", "wasmtime-environ", "wat", "winch-codegen", @@ -4043,7 +4025,7 @@ dependencies = [ "similar", "target-lexicon", "toml", - "wasmparser 0.121.0", + "wasmparser", "wasmtime-environ", "wat", "winch-codegen", @@ -4213,9 +4195,9 @@ dependencies = [ [[package]] name = "wit-bindgen" -version = "0.15.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0e367a0bdb6b9f6db939a21749dfcd398b62a23f58afa5c44e7de16289dbeba" +checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" dependencies = [ "bitflags 2.4.1", "wit-bindgen-rust-macro", @@ -4223,33 +4205,33 @@ dependencies = [ [[package]] name = "wit-bindgen-core" -version = "0.15.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147bee3fde39f80da448dc971d3357c34f5810605e0ba59345ebe576002371c8" +checksum = "a3d22547a645a7d3e4311b977a34f12e1d47df48125dc06e11e45984c99282ed" dependencies = [ "anyhow", - "wit-component 0.18.2", - "wit-parser", + "wit-component 0.20.1", + "wit-parser 0.13.1", ] [[package]] name = "wit-bindgen-rust" -version = "0.15.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3033046c0f9112a67dc6c1e4281347c8d5f1e01d4cafc01321c259d45e3b8e4f" +checksum = "c6a691b95d07cc4e7f7aa259b480f7f0208c4ded49406fd4f8bfd5a5a61c5db1" dependencies = [ "anyhow", "heck", "wasm-metadata", "wit-bindgen-core", - "wit-component 0.18.2", + "wit-component 0.20.1", ] [[package]] name = "wit-bindgen-rust-macro" -version = "0.15.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f191047320b2c8bd05a5d367a28c7fe0ad409d43153efc8881aa775a652ca112" +checksum = "763cc6195d4ede622e5388051e381d397930016c8dc2f1199d3b48eb26781b6a" dependencies = [ "anyhow", "proc-macro2", @@ -4257,14 +4239,14 @@ dependencies = [ "syn 2.0.32", "wit-bindgen-core", "wit-bindgen-rust", - "wit-component 0.18.2", + "wit-component 0.20.1", ] [[package]] name = "wit-component" -version = "0.18.2" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a35a2a9992898c9d27f1664001860595a4bc99d32dd3599d547412e17d7e2" +checksum = "331de496d439010797c17637d8002712b9b69110f1669164c09dfa226ad277bb" dependencies = [ "anyhow", "bitflags 2.4.1", @@ -4273,17 +4255,17 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "wasm-encoder 0.38.1", + "wasm-encoder", "wasm-metadata", - "wasmparser 0.118.1", - "wit-parser", + "wasmparser", + "wit-parser 0.13.1", ] [[package]] name = "wit-component" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "331de496d439010797c17637d8002712b9b69110f1669164c09dfa226ad277bb" +checksum = "be60cd1b2ff7919305301d0c27528d4867bd793afe890ba3837743da9655d91b" dependencies = [ "anyhow", "bitflags 2.4.1", @@ -4292,10 +4274,10 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "wasm-encoder 0.41.0", + "wasm-encoder", "wasm-metadata", - "wasmparser 0.121.0", - "wit-parser", + "wasmparser", + "wit-parser 0.14.0", ] [[package]] @@ -4315,6 +4297,24 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "wit-parser" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee4ad7310367bf272507c0c8e0c74a80b4ed586b833f7c7ca0b7588f686f11a" +dependencies = [ + "anyhow", + "id-arena", + "indexmap 2.0.0", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + [[package]] name = "witx" version = "0.9.1" diff --git a/Cargo.toml b/Cargo.toml index 18b6c0c17548..2e7ebfd6bdd7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -230,18 +230,18 @@ io-extras = "0.18.0" rustix = "0.38.21" is-terminal = "0.4.0" # wit-bindgen: -wit-bindgen = { version = "0.15.0", default-features = false } +wit-bindgen = { version = "0.17.0", default-features = false } # wasm-tools family: -wasmparser = "0.121.0" -wat = "1.0.85" -wast = "70.0.2" -wasmprinter = "0.2.78" -wasm-encoder = "0.41.0" -wasm-smith = "0.15.1" -wasm-mutate = "0.2.46" -wit-parser = "0.13.1" -wit-component = "0.20.1" +wasmparser = "0.121.2" +wat = "1.0.88" +wast = "71.0.1" +wasmprinter = "0.2.80" +wasm-encoder = "0.41.2" +wasm-smith = "0.16.1" +wasm-mutate = "0.2.48" +wit-parser = "0.14.0" +wit-component = "0.21.0" # Non-Bytecode Alliance maintained dependencies: # -------------------------- diff --git a/crates/fuzzing/src/generators/module.rs b/crates/fuzzing/src/generators/module.rs index e274220212cd..b669ff25d71c 100644 --- a/crates/fuzzing/src/generators/module.rs +++ b/crates/fuzzing/src/generators/module.rs @@ -62,7 +62,7 @@ impl ModuleConfig { let mut module = wasm_smith::Module::new(self.config.clone(), input)?; if let Some(default_fuel) = default_fuel { - module.ensure_termination(default_fuel); + module.ensure_termination(default_fuel).unwrap(); } Ok(module) diff --git a/crates/fuzzing/src/oracles.rs b/crates/fuzzing/src/oracles.rs index 8831865d9db0..9381e5785537 100644 --- a/crates/fuzzing/src/oracles.rs +++ b/crates/fuzzing/src/oracles.rs @@ -21,6 +21,7 @@ mod stacks; use self::diff_wasmtime::WasmtimeInstance; use self::engine::{DiffEngine, DiffInstance}; use crate::generators::{self, DiffValue, DiffValueType}; +use crate::single_module_fuzzer::KnownValid; use arbitrary::Arbitrary; pub use stacks::check_stacks; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering::SeqCst}; @@ -135,7 +136,12 @@ pub enum Timeout { /// panic or segfault or anything else that can be detected "passively". /// /// The engine will be configured using provided config. -pub fn instantiate(wasm: &[u8], known_valid: bool, config: &generators::Config, timeout: Timeout) { +pub fn instantiate( + wasm: &[u8], + known_valid: KnownValid, + config: &generators::Config, + timeout: Timeout, +) { let mut store = config.to_store(); let module = match compile_module(store.engine(), wasm, known_valid, config) { @@ -193,7 +199,7 @@ pub enum Command { /// The modules are expected to *not* have start functions as no timeouts are configured. pub fn instantiate_many( modules: &[Vec], - known_valid: bool, + known_valid: KnownValid, config: &generators::Config, commands: &[Command], ) { @@ -246,13 +252,13 @@ pub fn instantiate_many( fn compile_module( engine: &Engine, bytes: &[u8], - known_valid: bool, + known_valid: KnownValid, config: &generators::Config, ) -> Option { log_wasm(bytes); match config.compile(engine, bytes) { Ok(module) => Some(module), - Err(_) if !known_valid => None, + Err(_) if known_valid == KnownValid::No => None, Err(e) => { if let generators::InstanceAllocationStrategy::Pooling(c) = &config.wasmtime.strategy { // When using the pooling allocator, accept failures to compile @@ -602,7 +608,7 @@ pub fn table_ops( let wasm = ops.to_wasm_binary(); log_wasm(&wasm); - let module = match compile_module(store.engine(), &wasm, false, &fuzz_config) { + let module = match compile_module(store.engine(), &wasm, KnownValid::No, &fuzz_config) { Some(m) => m, None => return 0, }; diff --git a/crates/fuzzing/src/oracles/diff_wasmtime.rs b/crates/fuzzing/src/oracles/diff_wasmtime.rs index 9333c02e6579..f844a1901270 100644 --- a/crates/fuzzing/src/oracles/diff_wasmtime.rs +++ b/crates/fuzzing/src/oracles/diff_wasmtime.rs @@ -4,6 +4,7 @@ use crate::generators::{self, DiffValue, DiffValueType, WasmtimeConfig}; use crate::oracles::dummy; use crate::oracles::engine::DiffInstance; use crate::oracles::{compile_module, engine::DiffEngine, StoreLimits}; +use crate::single_module_fuzzer::KnownValid; use anyhow::{Context, Error, Result}; use arbitrary::Unstructured; use wasmtime::{Extern, FuncType, Instance, Module, Store, Trap, Val}; @@ -36,7 +37,7 @@ impl DiffEngine for WasmtimeEngine { fn instantiate(&mut self, wasm: &[u8]) -> Result> { let store = self.config.to_store(); - let module = compile_module(store.engine(), wasm, true, &self.config).unwrap(); + let module = compile_module(store.engine(), wasm, KnownValid::Yes, &self.config).unwrap(); let instance = WasmtimeInstance::new(store, module)?; Ok(Box::new(instance)) } diff --git a/crates/fuzzing/src/single_module_fuzzer.rs b/crates/fuzzing/src/single_module_fuzzer.rs index 6e2ef0738fde..3a0f3cb13036 100644 --- a/crates/fuzzing/src/single_module_fuzzer.rs +++ b/crates/fuzzing/src/single_module_fuzzer.rs @@ -95,8 +95,8 @@ macro_rules! single_module_fuzzer { /// module. pub fn execute<'a, T, U>( input: &'a [u8], - run: fn(&[u8], bool, T, &mut Unstructured<'a>) -> Result, - gen_module: fn(&mut T, &mut Unstructured<'a>) -> Result>, + run: fn(&[u8], KnownValid, T, &mut Unstructured<'a>) -> Result, + gen_module: fn(&mut T, &mut Unstructured<'a>) -> Result<(Vec, KnownValid)>, ) -> Result where T: Arbitrary<'a>, @@ -113,12 +113,29 @@ where }; let mut u = Unstructured::new(fuzz_data); let mut config = u.arbitrary()?; - let generated = gen_module(&mut config, &mut u)?; + let (generated, known_valid) = gen_module(&mut config, &mut u)?; let module = module_in_input.unwrap_or(&generated); if let Ok(file) = std::env::var("WRITE_FUZZ_INPUT_TO") { std::fs::write(file, encode_module(&module, &fuzz_data)).unwrap(); } - run(module, module_in_input.is_none(), config, &mut u) + let known_valid = if module_in_input.is_some() { + KnownValid::No + } else { + known_valid + }; + run(module, known_valid, config, &mut u) +} + +/// Used as part of `execute` above to determine whether a module is known to +/// be valid ahead of time. +#[derive(Debug, PartialEq, Eq, Copy, Clone)] +pub enum KnownValid { + /// This module is known to be valid so it should assert compilation + /// succeeds for example. + Yes, + /// This module is not known to be valid and it may not compile + /// successfully. Note that it's also not known to compile unsuccessfully. + No, } const SECTION_NAME: &str = "wasmtime-fuzz-input"; @@ -133,7 +150,7 @@ pub fn mutate( data: &mut [u8], mut size: usize, max_size: usize, - gen_module: fn(&mut T, &mut Unstructured<'_>) -> Result>, + gen_module: fn(&mut T, &mut Unstructured<'_>) -> Result<(Vec, KnownValid)>, mutate: fn(&mut [u8], usize, usize) -> usize, ) -> usize where @@ -170,7 +187,7 @@ where .arbitrary() .and_then(|mut config| gen_module(&mut config, &mut u)) { - Ok(module) => { + Ok((module, _known_valid)) => { let module = encode_module(&module, &data[..new_size]); if module.len() < max_size { @@ -295,10 +312,10 @@ mod tests { let run2 = run_config::<(u32, u32)>; if let Ok((module, known_valid)) = execute(&buf[..seed_size], run1, gen) { - assert!(known_valid); + assert_eq!(known_valid, KnownValid::Yes); let new_size = mutate(&mut buf, seed_size, max_size, gen, noop_mutate); if let Ok((module2, known_valid)) = execute(&buf[..new_size], run2, gen) { - assert!(!known_valid); + assert_eq!(known_valid, KnownValid::No); compares += 1; if module != module2 { panic!("modules differ"); @@ -313,21 +330,24 @@ mod tests { fn run_config( data: &[u8], - known_valid: bool, + known_valid: KnownValid, _: T, _: &mut Unstructured<'_>, - ) -> Result<(Vec, bool)> + ) -> Result<(Vec, KnownValid)> where T: for<'a> Arbitrary<'a>, { Ok((data.to_vec(), known_valid)) } - fn gen(_: &mut T, u: &mut Unstructured<'_>) -> Result> + fn gen(_: &mut T, u: &mut Unstructured<'_>) -> Result<(Vec, KnownValid)> where T: for<'a> Arbitrary<'a>, { - Ok(u.arbitrary::()?.to_bytes()) + Ok(( + u.arbitrary::()?.to_bytes(), + KnownValid::Yes, + )) } fn noop_mutate(_buf: &mut [u8], size: usize, _new_size: usize) -> usize { diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 99608a879eef..2eea42d97c4b 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -85,12 +85,6 @@ path = "fuzz_targets/stacks.rs" test = false doc = false -[[bin]] -name = "compile-maybe-invalid" -path = "fuzz_targets/compile-maybe-invalid.rs" -test = false -doc = false - [[bin]] name = "cranelift-fuzzgen" path = "fuzz_targets/cranelift-fuzzgen.rs" diff --git a/fuzz/fuzz_targets/compile-maybe-invalid.rs b/fuzz/fuzz_targets/compile-maybe-invalid.rs deleted file mode 100644 index 2cdb282f8598..000000000000 --- a/fuzz/fuzz_targets/compile-maybe-invalid.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![no_main] - -use libfuzzer_sys::fuzz_target; -use wasmtime::{Engine, Module}; -use wasmtime_fuzzing::wasm_smith::MaybeInvalidModule; - -fuzz_target!(|module: MaybeInvalidModule| { - let engine = Engine::default(); - let wasm = module.to_bytes(); - wasmtime_fuzzing::oracles::log_wasm(&wasm); - drop(Module::new(&engine, &wasm)); -}); diff --git a/fuzz/fuzz_targets/instantiate-many.rs b/fuzz/fuzz_targets/instantiate-many.rs index 48f1248a181d..0ee9fa2ebcbc 100644 --- a/fuzz/fuzz_targets/instantiate-many.rs +++ b/fuzz/fuzz_targets/instantiate-many.rs @@ -5,6 +5,7 @@ use libfuzzer_sys::arbitrary::{Result, Unstructured}; use libfuzzer_sys::fuzz_target; +use wasmtime_fuzzing::single_module_fuzzer::KnownValid; use wasmtime_fuzzing::{generators, oracles}; const MAX_MODULES: usize = 5; @@ -56,7 +57,7 @@ fn execute_one(data: &[u8]) -> Result<()> { .collect::>>()?, ); - oracles::instantiate_many(&modules, true, &config, &commands); + oracles::instantiate_many(&modules, KnownValid::Yes, &config, &commands); Ok(()) } diff --git a/fuzz/fuzz_targets/instantiate.rs b/fuzz/fuzz_targets/instantiate.rs index 8e552bea0dcd..cc5ae10f516b 100644 --- a/fuzz/fuzz_targets/instantiate.rs +++ b/fuzz/fuzz_targets/instantiate.rs @@ -3,6 +3,7 @@ use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured}; use wasmtime_fuzzing::generators::Config; use wasmtime_fuzzing::oracles::{instantiate, Timeout}; +use wasmtime_fuzzing::single_module_fuzzer::KnownValid; wasmtime_fuzzing::single_module_fuzzer!(execute gen_module); @@ -31,7 +32,7 @@ impl<'a> Arbitrary<'a> for InstantiateInput { fn execute( module: &[u8], - known_valid: bool, + known_valid: KnownValid, mut input: InstantiateInput, u: &mut Unstructured<'_>, ) -> Result<()> { @@ -39,21 +40,40 @@ fn execute( // If the input module isn't a "known valid" module then it can't be // relied on self-regulating itself, so force a timeout via epochs/fuel // in the configuration. - Timeout::None if !known_valid => input.config.generate_timeout(u)?, + Timeout::None if known_valid == KnownValid::No => input.config.generate_timeout(u)?, other => other, }; instantiate(module, known_valid, &input.config, timeout); Ok(()) } -fn gen_module(input: &mut InstantiateInput, u: &mut Unstructured<'_>) -> Result> { - let module = input.config.generate( - u, - if let Timeout::None = input.timeout { - Some(1000) - } else { - None - }, - )?; - Ok(module.to_bytes()) +fn gen_module( + input: &mut InstantiateInput, + u: &mut Unstructured<'_>, +) -> Result<(Vec, KnownValid)> { + // With a small-ish chance take raw fuzz input and put it in the module to + // stress module compilation/validation. In such a situation we can't use + // `ensure_termination` in wasm-smith so list the timeout as `None` to time + // out via epochs or Wasmtime-level fuel. + // + // Otherwise though if no timeout is configured use wasm-smith fuel to + // ensure termination. + let allow_invalid_funcs = u.ratio(1, 10)?; + + let default_fuel = if allow_invalid_funcs { + input.config.module_config.config.allow_invalid_funcs = true; + input.timeout = Timeout::None; + None + } else if let Timeout::None = input.timeout { + Some(1000) + } else { + None + }; + let module = input.config.generate(u, default_fuel)?; + let known_valid = if allow_invalid_funcs { + KnownValid::No + } else { + KnownValid::Yes + }; + Ok((module.to_bytes(), known_valid)) } diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock index b4cc454f488a..fd7a42fef762 100644 --- a/supply-chain/imports.lock +++ b/supply-chain/imports.lock @@ -1068,6 +1068,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wasm-encoder]] +version = "0.41.2" +when = "2024-02-12" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wasm-metadata]] version = "0.10.17" when = "2024-01-29" @@ -1075,6 +1082,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wasm-metadata]] +version = "0.10.20" +when = "2024-02-12" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wasm-mutate]] version = "0.2.46" when = "2024-01-29" @@ -1082,6 +1096,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wasm-mutate]] +version = "0.2.48" +when = "2024-02-12" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wasm-smith]] version = "0.15.1" when = "2024-01-29" @@ -1089,6 +1110,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wasm-smith]] +version = "0.16.1" +when = "2024-02-12" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wasmparser]] version = "0.118.1" when = "2023-11-29" @@ -1103,6 +1131,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wasmparser]] +version = "0.121.2" +when = "2024-02-12" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wasmprinter]] version = "0.2.78" when = "2024-01-29" @@ -1110,6 +1145,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wasmprinter]] +version = "0.2.80" +when = "2024-02-12" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wasmtime]] version = "17.0.0" when = "2024-01-25" @@ -1261,6 +1303,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wast]] +version = "71.0.1" +when = "2024-02-12" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wat]] version = "1.0.85" when = "2024-01-29" @@ -1268,6 +1317,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wat]] +version = "1.0.88" +when = "2024-02-12" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wiggle]] version = "17.0.0" when = "2024-01-25" @@ -1523,6 +1579,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wit-bindgen]] +version = "0.17.0" +when = "2024-02-05" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wit-bindgen-core]] version = "0.15.0" when = "2023-11-27" @@ -1530,6 +1593,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wit-bindgen-core]] +version = "0.17.0" +when = "2024-02-05" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wit-bindgen-rust]] version = "0.15.0" when = "2023-11-27" @@ -1537,6 +1607,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wit-bindgen-rust]] +version = "0.17.0" +when = "2024-02-05" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wit-bindgen-rust-macro]] version = "0.15.0" when = "2023-11-27" @@ -1544,6 +1621,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wit-bindgen-rust-macro]] +version = "0.17.0" +when = "2024-02-05" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wit-component]] version = "0.18.2" when = "2023-11-20" @@ -1558,6 +1642,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wit-component]] +version = "0.21.0" +when = "2024-02-12" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wit-parser]] version = "0.13.1" when = "2024-01-09" @@ -1565,6 +1656,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wit-parser]] +version = "0.14.0" +when = "2024-02-12" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[audits.embark-studios.wildcard-audits.spdx]] who = "Jake Shadle " criteria = "safe-to-deploy"