From f0bd680343b76a74124b38bbaaecaa33fdd46a3d Mon Sep 17 00:00:00 2001 From: Patrick Ventuzelo Date: Mon, 2 Sep 2019 11:08:40 +0200 Subject: [PATCH 1/3] validate_wasm fuzzer --- fuzz/Cargo.toml | 6 ++++++ fuzz/README.md | 6 +++++- fuzz/fuzz_targets/validate_wasm.rs | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 fuzz/fuzz_targets/validate_wasm.rs diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 5c37cb47ed3..8660fdd976b 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -10,6 +10,8 @@ cargo-fuzz = true [dependencies] wasmer-runtime = { path = "../lib/runtime" } +wasmer-runtime-core = { path = "../lib/runtime-core" } +wasmer = { path = "../" } libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" } # Prevent this from interfering with workspaces @@ -19,3 +21,7 @@ members = ["."] [[bin]] name = "simple_instantiate" path = "fuzz_targets/simple_instantiate.rs" + +[[bin]] +name = "validate_wasm" +path = "fuzz_targets/validate_wasm.rs" \ No newline at end of file diff --git a/fuzz/README.md b/fuzz/README.md index cac0a320a54..dda80ce7a6c 100644 --- a/fuzz/README.md +++ b/fuzz/README.md @@ -10,12 +10,16 @@ $ cargo install cargo-fuzz `cargo-fuzz` is documented in the [Rust Fuzz Book](https://rust-fuzz.github.io/book/cargo-fuzz.html). -## Running a fuzzer +## Running a fuzzer (simple_instantiate, validate_wasm) Once `cargo-fuzz` is installed, you can run the `simple_instantiate` fuzzer with ```sh cargo fuzz run simple_instantiate ``` +or the `validate_wasm` fuzzer +```sh +cargo fuzz run validate_wasm +``` You should see output that looks something like this: diff --git a/fuzz/fuzz_targets/validate_wasm.rs b/fuzz/fuzz_targets/validate_wasm.rs new file mode 100644 index 00000000000..0b2b09ecbb5 --- /dev/null +++ b/fuzz/fuzz_targets/validate_wasm.rs @@ -0,0 +1,19 @@ +#![no_main] +#[macro_use] extern crate libfuzzer_sys; + +extern crate wasmer_runtime_core; +extern crate wasmer; + +use wasmer_runtime_core::{ + backend::{Features}, +}; + +fuzz_target!(|data: &[u8]| { + let _ = wasmer::utils::is_wasm_binary(data); + let _ = wasmer_runtime_core::validate_and_report_errors_with_features( + &data, + Features { + // modify those values to explore additionnal part of wasmer + simd: false, threads: false, }, + ); +}); \ No newline at end of file From 9ba77aa1fc6f253458e06cd598690b12b3364cbd Mon Sep 17 00:00:00 2001 From: Patrick Ventuzelo <9038181+pventuzelo@users.noreply.github.com> Date: Mon, 2 Sep 2019 11:14:05 +0200 Subject: [PATCH 2/3] [formating] add new line Cargo.toml --- fuzz/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 8660fdd976b..229a36e7f89 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -24,4 +24,4 @@ path = "fuzz_targets/simple_instantiate.rs" [[bin]] name = "validate_wasm" -path = "fuzz_targets/validate_wasm.rs" \ No newline at end of file +path = "fuzz_targets/validate_wasm.rs" From afa6d6f52cd9fce1b1e8a14176cccb04209532ba Mon Sep 17 00:00:00 2001 From: Patrick Ventuzelo <9038181+pventuzelo@users.noreply.github.com> Date: Mon, 2 Sep 2019 11:14:40 +0200 Subject: [PATCH 3/3] [formatting] add new line validate_wasm.rs --- fuzz/fuzz_targets/validate_wasm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fuzz/fuzz_targets/validate_wasm.rs b/fuzz/fuzz_targets/validate_wasm.rs index 0b2b09ecbb5..4f5662bc8a2 100644 --- a/fuzz/fuzz_targets/validate_wasm.rs +++ b/fuzz/fuzz_targets/validate_wasm.rs @@ -16,4 +16,4 @@ fuzz_target!(|data: &[u8]| { // modify those values to explore additionnal part of wasmer simd: false, threads: false, }, ); -}); \ No newline at end of file +});