rust-fuzz/libfuzzer

How i can downgrade libFuzzer ?

hpkit opened this issue · 5 comments

hpkit commented

I try use https://lib.rs/crates/libfuzzer-sys information to fuzz rust code.

After run:
cargo rustc --
-C passes='sancov'
-C llvm-args='-sanitizer-coverage-level=3'
-Z sanitizer=address

I run my target/debug/fuzzed

And see:
-fsanitize-coverage=trace-pc-guard is no longer supported by libFuzzer.
Please either migrate to a compiler that supports -fsanitize=fuzzer
or use an older version of libFuzzer

How i can use an older version of libFuzzer ?

are you using cargo-fuzz? if so you may need to update rust-fuzz/cargo-fuzz#189

hpkit commented

I try to do this:

  1. First create a new cargo project:

$ cargo new --bin fuzzed
$ cd fuzzed

  1. Then add a dependency on the fuzzer-sys crate and your own crate:

[dependencies]
libfuzzer-sys = "0.3.4"
your_crate = { path = "../path/to/your/crate" }

  1. Change the fuzzed/src/main.rs to fuzz your code:

#![no_main]

use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
// code to fuzz goes here
});

  1. Build by running the following command:
    cargo rustc --
    -C passes='sancov'
    -C llvm-args='-sanitizer-coverage-level=3'
    -Z sanitizer=address

  2. And finally, run the fuzzer:

$ ./target/debug/fuzzed

OS Ubuntu 20.04.

Thanks for the info. I can reproduce this on my Mac

If you change it to:

cargo rustc --
  -C passes='sancov'
  -C llvm-args='-sanitizer-coverage-level=3'
  -C llvm-args='-sanitizer-coverage-inline-8bit-counters \
  -Z sanitizer=address

This should resolve your issue. I guess it defaults to -fsanitize-coverage=trace-pc-guard, which is apparently now deprecated. Some more info here: https://clang.llvm.org/docs/SanitizerCoverage.html

I'll update the README

thejh commented

llvm/llvm-project@a523135 is where the instrumentation was switched over; that's in clang. the deprecation warning is in libfuzzer. therefore, if your libfuzzer is newer than your LLVM/clang version, this happens.