Skip to content

Commit bc18acc

Browse files
write a little readme
1 parent 217772c commit bc18acc

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

lib/fuzzer/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
There are two things the fuzzer is storing: explored features and the corpus.
2+
3+
Explored features is a sorted buffer of u32 values. Explored feature is
4+
anything "interesting" that happened in the code when we run it with some input
5+
and *it did not crash*. Different "interesting things" should correspond to
6+
different u32 values but collisions never 100% avoidable. Explored features are
7+
not shared among different workers.
8+
9+
Currently tracked "interesting things" are:
10+
11+
* taken edges in the CFG
12+
* address of cmp instructions executed
13+
* address of switch statements executed
14+
* indirect calls
15+
16+
Fuzzer is trying to maximize the number of unique explored features over all
17+
inputs.
18+
19+
The corpus is a set of inputs where input is some array of bytes. The initial
20+
corpus is either provided by the user or generated randomly. The corpus is
21+
stored as two arrays that are shared among all workers. One of the arrays
22+
stores the inputs, densely packed one after another. The other is storing some
23+
metadata and indexes of string ends. Whenever some input explores a new
24+
feature, it is added to the corpus. The corpus is never shrunk, only appended.
25+
26+
All that the fuzzer does is pick random input, mutate it, see if it hits any
27+
new features and if so, add the mutated input to the corpus and the new
28+
features to explored features.
29+
30+
Every file starts with a more detailed documentation on the part of the fuzzer
31+
that is implemented in that file:
32+
33+
* `feature_capture.zig` - storing and deduplication of features that the user
34+
code is emitting
35+
* `InputPool*.zig` - corpus implementations
36+
* `main.zig` - the main loop
37+
* `memory_mapped_list*.zig` - shared growable memory mapped files
38+
* `mutate.zig` - mutations
39+
40+
Possible improvements:
41+
42+
* Prioritize mutating inputs that hit rare features
43+
* Table of recently compared values used in mutations
44+
* In-place mutation to avoid copying?
45+
* Implement more mutations
46+
* Multithreading
47+
* Maybe use hash table for explored features instead of sorted array
48+

lib/fuzzer/util.zig

Whitespace-only changes.

0 commit comments

Comments
 (0)