Enable simd fuzzing on oss-fuzz (#3152)

* Enable simd fuzzing on oss-fuzz

This commit generally enables the simd feature while fuzzing, which
should affect almost all fuzzers. For fuzzers that just throw random
data at the wall and see what sticks, this means that they'll now be
able to throw simd-shaped data at the wall and have it stick. For
wasm-smith-based fuzzers this commit also updates wasm-smith to 0.6.0
which allows further configuring the `SwarmConfig` after generation,
notably allowing `instantiate-swarm` to generate modules using simd
using `wasm-smith`. This should much more reliably feed simd-related
things into the fuzzers.

Finally, this commit updates wasmtime to avoid usage of the general
`wasm_smith::Module` generator to instead use a Wasmtime-specific custom
default configuration which enables various features we have
implemented.

* Allow dummy table creation to fail

Tables might creation for imports may exceed the memory limit on the
store, which we'll want to gracefully recover from and not fail the
fuzzers.
This commit is contained in:
Alex Crichton
2021-08-05 16:24:42 -05:00
committed by GitHub
parent 214c5f862d
commit bb85366a3b
12 changed files with 110 additions and 47 deletions

View File

@@ -116,3 +116,37 @@ impl<'a> Arbitrary<'a> for SpecTest {
(1, Some(std::mem::size_of::<usize>()))
}
}
/// Type alias for wasm-smith generated modules using wasmtime's default
/// configuration.
pub type GeneratedModule = wasm_smith::ConfiguredModule<WasmtimeDefaultConfig>;
/// Wasmtime-specific default configuration for wasm-smith-generated modules.
#[derive(Arbitrary, Clone, Debug)]
pub struct WasmtimeDefaultConfig;
impl wasm_smith::Config for WasmtimeDefaultConfig {
// Allow multi-memory to get exercised
fn max_memories(&self) -> usize {
2
}
// Allow multi-table (reference types) to get exercised
fn max_tables(&self) -> usize {
4
}
// Turn some wasm features default-on for those that have a finished
// implementation in Wasmtime.
fn simd_enabled(&self) -> bool {
true
}
fn reference_types_enabled(&self) -> bool {
true
}
fn bulk_memory_enabled(&self) -> bool {
true
}
}