summaryrefslogtreecommitdiff
path: root/fuzz/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'fuzz/README.md')
-rw-r--r--fuzz/README.md42
1 files changed, 42 insertions, 0 deletions
diff --git a/fuzz/README.md b/fuzz/README.md
new file mode 100644
index 0000000..6b5f4ae
--- /dev/null
+++ b/fuzz/README.md
@@ -0,0 +1,42 @@
1# fuzz testing
2
3This repository contains a binary used for fuzz testing.
4
5# Acknowledgments
6
7The fuzz setup with AFL++ comes from [Ryan Liptak's](https://www.ryanliptak.com/blog/fuzzing-zig-code/) blog post. See [this example repo](https://github.com/squeek502/zig-fuzzing-example) too.
8
9# Prerequisites
10
11To build the fuzz binary we need the `afl-clang-lto` binary in the system path.
12The recommended way to get that is to [install AFL++](https://github.com/AFLplusplus/AFLplusplus/blob/stable/docs/INSTALL.md).
13
14If you don't want to install it system-wide you can also do this instead:
15```
16make PREFIX=$HOME/local install
17```
18then make sure that `$HOME/local/bin` is in your system path.
19
20# Build and run
21
22Once AFL++ is installed, build the fuzz binary:
23```
24$ zig build fuzz
25```
26
27Finally to run the fuzzer do this:
28```
29$ afl-fuzz -i - -o fuzz/outputs -- ./zig-out/bin/fuzz
30```
31
32Note that `afl-fuzz` might complain about core dumps being sent to an external utility (usually systemd).
33
34You'll have to do this as root:
35```
36# echo core > /proc/sys/kernel/core_pattern
37```
38
39`afl-fuzz` might also complain about the scaling governor, setting `AFL_SKIP_CPUFREQ` as suggested is good enough:
40```
41$ AFL_SKIP_CPUFREQ=1 afl-fuzz -i - -o fuzz/outputs -- ./zig-out/bin/fuzz
42```