Skip to content

Commit ebe053b

Browse files
committed
Update fuzzing instructions for libFuzzer/cargo-fuzz
1 parent 9de51f0 commit ebe053b

File tree

1 file changed

+40
-10
lines changed

1 file changed

+40
-10
lines changed

fuzz/README.md

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@ Fuzz tests generate a ton of random parameter arguments to the program and then
44

55
## How does it work?
66

7-
Typically, Travis CI will run `travis-fuzz.sh` on one of the environments the automated tests are configured for.
8-
This is the most time-consuming component of the continuous integration workflow, so it is recommended that you detect
9-
issues locally, and Travis merely acts as a sanity check. Fuzzing is further only effective with
10-
a lot of CPU time, indicating that if crash scenarios are discovered on Travis with its low
11-
runtime constraints, the crash is caused relatively easily.
7+
Typically, Travis CI will run `travis-fuzz.sh` on one of the environments the automated tests are
8+
configured for. This is the most time-consuming component of the continuous integration workflow,
9+
so it is recommended that you detect issues locally, and Travis merely acts as a sanity check.
10+
Fuzzing is further only effective with a lot of CPU time, indicating that if crash scenarios are
11+
discovered on Travis with its low runtime constraints, the crash is caused relatively easily.
1212

1313
## How do I run fuzz tests locally?
1414

15-
You typically won't need to run the entire combination of different fuzzing tools. For local execution, `honggfuzz`
16-
should be more than sufficient.
15+
We support multiple fuzzing engines such as `honggfuzz`, `libFuzzer` and `AFL`. You typically won't
16+
need to run the entire suite of different fuzzing tools. For local execution, `honggfuzz`should be
17+
more than sufficient.
1718

1819
### Setup
19-
20+
#### Honggfuzz
2021
To install `honggfuzz`, simply run
2122

2223
```shell
@@ -31,9 +32,18 @@ cargo update -p honggfuzz --precise "0.5.52"
3132
cargo install --force honggfuzz --version "0.5.52"
3233
```
3334

35+
#### cargo-fuzz / libFuzzer
36+
To install `cargo-fuzz`, simply run
37+
38+
```shell
39+
cargo update
40+
cargo install --force cargo-fuzz
41+
```
42+
3443
### Execution
3544

36-
To run the Hongg fuzzer, do
45+
#### Honggfuzz
46+
To run fuzzing using `honggfuzz`, do
3747

3848
```shell
3949
export CPU_COUNT=1 # replace as needed
@@ -46,6 +56,25 @@ cargo hfuzz run $TARGET
4656

4757
(Or, for a prettier output, replace the last line with `cargo --color always hfuzz run $TARGET`.)
4858

59+
#### cargo-fuzz / libFuzzer
60+
To run fuzzing using `cargo-fuzz / libFuzzer`, run
61+
62+
```shell
63+
rustup install nightly # Note: libFuzzer requires a nightly version of rust.
64+
cargo +nightly fuzz run --features "libfuzzer_fuzz" msg_ping_target
65+
```
66+
Note: If you encounter a `SIGKILL` during run/build check for OOM in kernel logs and consider
67+
increasing RAM size for VM.
68+
69+
If you wish to just generate fuzzing binary executables for `libFuzzer` and not run them:
70+
```shell
71+
cargo +nightly fuzz build --features "libfuzzer_fuzz" msg_ping_target
72+
# Generates binary artifact in path ./target/aarch64-unknown-linux-gnu/release/msg_ping_target
73+
# Exact path depends on your system architecture.
74+
```
75+
You can upload the build artifact generated above to `ClusterFuzz` for distributed fuzzing.
76+
77+
### List Fuzzing Targets
4978
To see a list of available fuzzing targets, run:
5079

5180
```shell
@@ -54,7 +83,8 @@ ls ./src/bin/
5483

5584
## A fuzz test failed on Travis, what do I do?
5685

57-
You're trying to create a PR, but need to find the underlying cause of that pesky fuzz failure blocking the merge?
86+
You're trying to create a PR, but need to find the underlying cause of that pesky fuzz failure
87+
blocking the merge?
5888

5989
Worry not, for this is easily traced.
6090

0 commit comments

Comments
 (0)