Debian Codegraph @

afl-fuzz/README.md

raw symbols SCIP
1 Fuzzing with afl-fuzz
2 =====================
3
4 FIXME: Running these commands sucks. Need a script or something.
5
6 To use `cargo afl`:
7
8 * Install `binutils-gold` (your program won't build otherwise).
9 * `cargo install cargo-afl`
10
11 To build and run the fuzzer:
12
13 ```sh
14 cargo afl build --release
15 AFL_SKIP_CPUFREQ=1 cargo afl fuzz -i input/ -o out -S f0 target/release/rsvg-afl-fuzz
16 ```
17
18 For each CPU core, change `-S f0` for `-S f1`, `-S f2`, etc. To use
19 multiple CPU cores, run that command with a different `-S` option for
20 each core; see [the multicore
21 documentation](https://github.com/AFLplusplus/AFLplusplus/blob/stable/docs/fuzzing_in_depth.md#c-using-multiple-cores)
22 for details on changing the fuzz configuration for each job.
23
24 AFL complained when my kernel's configuration for corefiles was this:
25
26 ```sh
27 $ cat /proc/sys/kernel/core_pattern
28 |/bin/false
29 ```
30
31 Set it with `echo core > /proc/sys/kernel/core_pattern` and AFL was
32 happy. Alternatively, set `AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1`
33 but you won't get corefiles.
34
35 Note: afl++ comes with pre-written dictionaries for svg/css/xml
36 (slightly incomplete, but a useful starting point). However, these
37 **don't work out of the box** because the `-x` option to include a
38 dictionary (or a directory with dictionaries) complains if a
39 dictionary file is bigger than **128 bytes**. This is... very
40 limited? We may need to split the SVG dictionary into many little
41 files.
42
43 TODO: Help Wanted
44 ------------------
45
46 * We shouldn't fuzz on the CI machines, but we should make it easy for people to
47 run the fuzzing framework. Make a script (and fix the CI container image) to
48 do the above well, taking the following into account.
49
50 * Investigate
51 [the many options in afl++](https://github.com/AFLplusplus/AFLplusplus/blob/stable/docs/fuzzing_in_depth.md).
52 For example, it recommends setting up a main fuzzer instance with `-M` and
53 secondary fuzzers with `-S` for each additional core. Also, it recommends
54 using different mutators and power schedules - no idea what those do.
55
56 * Improve the corpus. The files in `input/` are basic SVGs but they do not
57 exercise every major feature of librsvg. Maybe pick up relevant files from the
58 test suite and drop them in there.
59
60 * Write dictionaries that can actually be consumed by afl++. See the comment
61 above on dictionary files needing to be below 128 bytes in size.
62
63 * The afl++ documentation mentions that its output directory is pretty taxing on
64 I/O systems, and for example SSDs. It recommends using a tmpfs as a RAM disk
65 for that. Integrate that into the scripts.
66
67 * Do we need a VM with a kernel setup up just like afl++ likes it?