Skip to content

Fuzzing and rust coverage#5595

Closed
catenacyber wants to merge 2 commits intoOISF:masterfrom
catenacyber:fuzz-rust-cov-v1
Closed

Fuzzing and rust coverage#5595
catenacyber wants to merge 2 commits intoOISF:masterfrom
catenacyber:fuzz-rust-cov-v1

Conversation

@catenacyber
Copy link
Contributor

Link to redmine ticket:
https://redmine.openinfosecfoundation.org/issues/4125

Describe changes:

  • do not rebuild rust std when instrumenting for coverage (as both seem incompatible)
  • fuzz driver accepts directories as well as single files now

TL;DR
To get coverage report including rust with oss-fuzz, we will also need rustc changes, and oss-fuzz changes
To get this manually is possible, cf below

To get coverage, I compile with

export RUSTFLAGS="$RUSTFLAGS -Zinstrument-coverage"
export CFLAGS="-g -O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fprofile-instr-generate -fcoverage-mapping -pthread -fsanitize=fuzzer-no-link"
export CXXFLAGS="-g -O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fprofile-instr-generate -fcoverage-mapping -pthread -fsanitize=fuzzer-no-link -stdlib=libc++"

I also run in rust subdirectory

abspath=`cargo metadata | jq -r '.workspace_root'`
export RUSTFLAGS="$RUSTFLAGS --remap-path-prefix src=$abspath/src"

to get the absolute file paths for suricata's crate, so that llvm-cov can generate a nice report

You need some fresh rust nightly compiler and llvm 10
For LLVM 11 and 12, rust compiler is not ready yet cf rust-lang/rust#79365

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant