diff options
| author | 2022-08-21 12:13:40 +0200 | |
|---|---|---|
| committer | 2022-08-21 13:43:18 +0200 | |
| commit | bbb8815da1f3f141ea70befd28055f7b17c6a26d (patch) | |
| tree | cd0f74de6df7124847c05c36919c510237494638 | |
| parent | build: force the use of stage1 (diff) | |
| download | zig-sqlite-bbb8815da1f3f141ea70befd28055f7b17c6a26d.tar.gz zig-sqlite-bbb8815da1f3f141ea70befd28055f7b17c6a26d.tar.xz zig-sqlite-bbb8815da1f3f141ea70befd28055f7b17c6a26d.zip | |
fuzz: add a readme explaining how to use it
Diffstat (limited to '')
| -rw-r--r-- | fuzz/README.md | 42 |
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 | |||
| 3 | This repository contains a binary used for fuzz testing. | ||
| 4 | |||
| 5 | # Acknowledgments | ||
| 6 | |||
| 7 | The 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 | |||
| 11 | To build the fuzz binary we need the `afl-clang-lto` binary in the system path. | ||
| 12 | The recommended way to get that is to [install AFL++](https://github.com/AFLplusplus/AFLplusplus/blob/stable/docs/INSTALL.md). | ||
| 13 | |||
| 14 | If you don't want to install it system-wide you can also do this instead: | ||
| 15 | ``` | ||
| 16 | make PREFIX=$HOME/local install | ||
| 17 | ``` | ||
| 18 | then make sure that `$HOME/local/bin` is in your system path. | ||
| 19 | |||
| 20 | # Build and run | ||
| 21 | |||
| 22 | Once AFL++ is installed, build the fuzz binary: | ||
| 23 | ``` | ||
| 24 | $ zig build fuzz | ||
| 25 | ``` | ||
| 26 | |||
| 27 | Finally to run the fuzzer do this: | ||
| 28 | ``` | ||
| 29 | $ afl-fuzz -i - -o fuzz/outputs -- ./zig-out/bin/fuzz | ||
| 30 | ``` | ||
| 31 | |||
| 32 | Note that `afl-fuzz` might complain about core dumps being sent to an external utility (usually systemd). | ||
| 33 | |||
| 34 | You'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 | ``` | ||