Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuzzer #182

Merged
merged 4 commits into from
Aug 29, 2024
Merged

Fuzzer #182

merged 4 commits into from
Aug 29, 2024

Conversation

martinling
Copy link
Member

@martinling martinling commented Aug 27, 2024

This PR adds a fuzzer which tries to break the decoder under the following rules:

  • The decoder input may be any number of timestamped raw packets.
  • No constraints are placed on the number, length or content of packets.
  • To avoid uninteresting overflows/underflows in the timestamp compression, timestamps are constrained to start with a 32-bit value and increment in 32-bit deltas.

This approach very quickly identified some failures, which are fixed in the following commits.

The fuzzing is implemented using the libfuzzer_sys crate. We can't use cargo-fuzz in this case because we are testing private internal APIs. Instead, the fuzzer is implemented as a standalone example program which imports required modules directly.

The fuzzer can be run with cargo run --features fuzzer --example fuzzer, but for best results it is necessary to use the nightly compiler and build with:

cargo +nightly rustc --features fuzzer --example fuzzer -- \
     -C passes='sancov-module' \
     -C llvm-args='-sanitizer-coverage-level=3' \
     -C llvm-args='-sanitizer-coverage-inline-8bit-counters' \
     -Z sanitizer=address

and then run with:

target/debug/examples/fuzzer

@martinling martinling marked this pull request as ready for review August 29, 2024 12:51
@miek miek merged commit 7e14897 into greatscottgadgets:main Aug 29, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants