From a6cb56d450751695dd4fe259845800fec24eac94 Mon Sep 17 00:00:00 2001 From: Paul Grandperrin Date: Wed, 3 Mar 2021 17:25:44 +0100 Subject: [PATCH 1/7] Better error message when version of honggfuzz bin and lib do not match fixes #48 --- build.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index a26a276..8785093 100644 --- a/build.rs +++ b/build.rs @@ -22,7 +22,10 @@ fn main() { // check that "cargo hfuzz" command is at the same version as this file let honggfuzz_build_version = env::var("CARGO_HONGGFUZZ_BUILD_VERSION").unwrap_or("unknown".to_string()); if VERSION != honggfuzz_build_version { - eprintln!("honggfuzz dependency ({}) and build command ({}) versions do not match", + eprintln!("The version of the honggfuzz library dependency ({0}) and the version of the `cargo-hfuzz` executable ({1}) do not match.\n\ + If updating both by running `cargo update` and `cargo install honggfuzz` does not work, you can either:\n\ + - change the dependency in `Cargo.toml` to `honggfuzz = \"={1}\"`\n\ + - or run `cargo install honggfuzz --version {0}`", VERSION, honggfuzz_build_version); process::exit(1); } From f45aef1b59736fcfc215eca09aca42e49bbf36db Mon Sep 17 00:00:00 2001 From: Paul Grandperrin Date: Wed, 3 Mar 2021 17:43:04 +0100 Subject: [PATCH 2/7] Release 0.5.54 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c4de12e..80d9b64 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "honggfuzz" -version = "0.5.53" +version = "0.5.54" edition = "2018" authors = ["Paul Grandperrin "] license = "MIT/Apache-2.0/Unlicense/WTFPL" From 39623459e4d6655e378461a56fe51e8fe6b1b45a Mon Sep 17 00:00:00 2001 From: Paul Grandperrin Date: Wed, 28 Apr 2021 22:26:16 +0200 Subject: [PATCH 3/7] complete .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 68a4270..753367d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,7 @@ /target **/*.rs.bk **/Cargo.lock +example/hfuzz_target +example/hfuzz_workspace +example/target + From 4dcd4eae4ee837592dd7952aad2d83cc0c7aefa3 Mon Sep 17 00:00:00 2001 From: ptrus Date: Fri, 4 Jun 2021 10:22:42 +0200 Subject: [PATCH 4/7] deps: replace unmaintained memmap (RUSTSEC-2020-0077) --- Cargo.toml | 2 +- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 80d9b64..ef81a88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,4 +36,4 @@ rand_chacha = "0.3" lazy_static = "1.4" [target.'cfg(fuzzing_debug)'.dependencies] -memmap = "0.7" +mapr = "0.8" diff --git a/src/lib.rs b/src/lib.rs index da292c1..c912450 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -296,7 +296,7 @@ pub fn fuzz(closure: F) where F: FnOnce(&[u8]) { pub fn fuzz(closure: F) where F: FnOnce(&[u8]) { use std::env; use std::fs::File; - use memmap::MmapOptions; + use mapr::MmapOptions; let filename = env::var("CARGO_HONGGFUZZ_CRASH_FILENAME").unwrap_or_else(|_|{ eprintln!("error: Environment variable CARGO_HONGGFUZZ_CRASH_FILENAME not set. Try launching with \"cargo hfuzz run-debug TARGET CRASH_FILENAME [ ARGS ... ]\""); From 7e0724bf64a5594d3c4c40624d02073a85440364 Mon Sep 17 00:00:00 2001 From: Chojan Shang Date: Fri, 31 Dec 2021 18:17:10 +0800 Subject: [PATCH 5/7] fix: sancov -> sancov-module Signed-off-by: Chojan Shang --- src/bin/cargo-hfuzz.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/cargo-hfuzz.rs b/src/bin/cargo-hfuzz.rs index 6d76d85..ee35421 100644 --- a/src/bin/cargo-hfuzz.rs +++ b/src/bin/cargo-hfuzz.rs @@ -182,7 +182,7 @@ fn hfuzz_build(args: T, crate_root: &Path, build_type: &BuildType) where T: s if *build_type == BuildType::ReleaseInstrumented { rustflags.push_str("\ - -C passes=sancov \ + -C passes=sancov-module \ -C llvm-args=-sanitizer-coverage-level=4 \ -C llvm-args=-sanitizer-coverage-trace-pc-guard \ -C llvm-args=-sanitizer-coverage-trace-divs \ From f357a544809e82bc04a08ef44e761fdca3b72de7 Mon Sep 17 00:00:00 2001 From: Chojan Shang Date: Sat, 1 Jan 2022 10:11:08 +0800 Subject: [PATCH 6/7] fix: compatible with the old llvm Signed-off-by: Chojan Shang --- Cargo.toml | 1 + src/bin/cargo-hfuzz.rs | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ef81a88..4fc93b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ maintenance = { status = "actively-developed" } [dependencies] arbitrary = "1" +rustc_version = "0.4" [dev-dependencies] rand = "0.8" diff --git a/src/bin/cargo-hfuzz.rs b/src/bin/cargo-hfuzz.rs index ee35421..1ac88b7 100644 --- a/src/bin/cargo-hfuzz.rs +++ b/src/bin/cargo-hfuzz.rs @@ -181,8 +181,20 @@ fn hfuzz_build(args: T, crate_root: &Path, build_type: &BuildType) where T: s "); if *build_type == BuildType::ReleaseInstrumented { + // The fix for now is to pass `-C passes=sancov-module` only to compilers + // for which the LLVM version is >= 13. + let version_meta = rustc_version::version_meta().unwrap(); + if version_meta.llvm_version.map_or(true, |v| v.major >= 13) { + rustflags.push_str("\ + -C passes=sancov-module \ + "); + } else { + rustflags.push_str("\ + -C passes=sancov \ + "); + }; + rustflags.push_str("\ - -C passes=sancov-module \ -C llvm-args=-sanitizer-coverage-level=4 \ -C llvm-args=-sanitizer-coverage-trace-pc-guard \ -C llvm-args=-sanitizer-coverage-trace-divs \ From 0d10837742db102fffe03eaf70da522352636ab5 Mon Sep 17 00:00:00 2001 From: Chojan Shang Date: Tue, 4 Jan 2022 13:13:45 +0800 Subject: [PATCH 7/7] fix: nightly only Signed-off-by: Chojan Shang --- src/bin/cargo-hfuzz.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bin/cargo-hfuzz.rs b/src/bin/cargo-hfuzz.rs index 1ac88b7..46d1639 100644 --- a/src/bin/cargo-hfuzz.rs +++ b/src/bin/cargo-hfuzz.rs @@ -181,10 +181,12 @@ fn hfuzz_build(args: T, crate_root: &Path, build_type: &BuildType) where T: s "); if *build_type == BuildType::ReleaseInstrumented { - // The fix for now is to pass `-C passes=sancov-module` only to compilers - // for which the LLVM version is >= 13. + // The new LLVM pass manager was not enabled in rustc 1.57 as expected: + // https://github.com/rust-lang/rust/pull/91263 + // The fix for now is to pass `-C passes=sancov-module` only to nightly + // compilers for which the LLVM version is >= 13. let version_meta = rustc_version::version_meta().unwrap(); - if version_meta.llvm_version.map_or(true, |v| v.major >= 13) { + if version_meta.channel == rustc_version::Channel::Nightly && version_meta.llvm_version.map_or(true, |v| v.major >= 13) { rustflags.push_str("\ -C passes=sancov-module \ ");