xref: /aosp_15_r20/external/AFLplusplus/docs/features.md (revision 08b48e0b10e97b33e7b60c5b6e2243bd915777f2)
1*08b48e0bSAndroid Build Coastguard Worker# Important features of AFL++
2*08b48e0bSAndroid Build Coastguard Worker
3*08b48e0bSAndroid Build Coastguard WorkerAFL++ supports llvm from 3.8 up to version 12, very fast binary fuzzing with
4*08b48e0bSAndroid Build Coastguard WorkerQEMU 5.1 with laf-intel and Redqueen, FRIDA mode, unicorn mode, gcc plugin, full
5*08b48e0bSAndroid Build Coastguard Worker*BSD, Mac OS, Solaris and Android support and much, much, much more.
6*08b48e0bSAndroid Build Coastguard Worker
7*08b48e0bSAndroid Build Coastguard Worker## Features and instrumentation
8*08b48e0bSAndroid Build Coastguard Worker
9*08b48e0bSAndroid Build Coastguard Worker| Feature/Instrumentation       | afl-gcc  | llvm      | gcc_plugin | FRIDA mode(9)  | QEMU mode(10)    | unicorn_mode(10) | nyx_mode(12) | coresight_mode(11) |
10*08b48e0bSAndroid Build Coastguard Worker| ------------------------------|:--------:|:---------:|:----------:|:--------------:|:----------------:|:----------------:|:------------:|:------------------:|
11*08b48e0bSAndroid Build Coastguard Worker| Threadsafe counters [A]       |          |    x(3)   |            |                |                  |                  |       x      |                    |
12*08b48e0bSAndroid Build Coastguard Worker| NeverZero           [B]       | x86[_64] |    x(1)   |      x     |        x       |         x        |         x        |              |                    |
13*08b48e0bSAndroid Build Coastguard Worker| Persistent Mode     [C]       |          |     x     |      x     | x86[_64]/arm64 | x86[_64]/arm[64] |         x        |              |                    |
14*08b48e0bSAndroid Build Coastguard Worker| LAF-Intel / CompCov [D]       |          |     x     |            |                | x86[_64]/arm[64] | x86[_64]/arm[64] |   x86[_64]   |                    |
15*08b48e0bSAndroid Build Coastguard Worker| CmpLog              [E]       |          |     x     |      x     | x86[_64]/arm64 | x86[_64]/arm[64] |                  |              |                    |
16*08b48e0bSAndroid Build Coastguard Worker| Selective Instrumentation [F] |          |     x     |      x     |        x       |         x        |                  |              |                    |
17*08b48e0bSAndroid Build Coastguard Worker| Non-Colliding Coverage    [G] |          |    x(4)   |            |                |       (x)(5)     |                  |              |                    |
18*08b48e0bSAndroid Build Coastguard Worker| Ngram prev_loc Coverage   [H] |          |    x(6)   |            |                |                  |                  |              |                    |
19*08b48e0bSAndroid Build Coastguard Worker| Context Coverage    [I]       |          |    x(6)   |            |                |                  |                  |              |                    |
20*08b48e0bSAndroid Build Coastguard Worker| Auto Dictionary     [J]       |          |    x(7)   |            |                |                  |                  |              |                    |
21*08b48e0bSAndroid Build Coastguard Worker| Snapshot Support    [K]       |          |   (x)(8)  |   (x)(8)   |                |       (x)(5)     |                  |       x      |                    |
22*08b48e0bSAndroid Build Coastguard Worker| Shared Memory Test cases  [L] |          |     x     |      x     | x86[_64]/arm64 |         x        |         x        |       x      |                    |
23*08b48e0bSAndroid Build Coastguard Worker
24*08b48e0bSAndroid Build Coastguard Worker## More information about features
25*08b48e0bSAndroid Build Coastguard Worker
26*08b48e0bSAndroid Build Coastguard WorkerA. Default is not thread-safe coverage counter updates for better performance,
27*08b48e0bSAndroid Build Coastguard Worker   see [instrumentation/README.llvm.md](../instrumentation/README.llvm.md)
28*08b48e0bSAndroid Build Coastguard Worker
29*08b48e0bSAndroid Build Coastguard WorkerB. On wrapping coverage counters (255 + 1), skip the 0 value and jump to 1
30*08b48e0bSAndroid Build Coastguard Worker   instead. This has shown to give better coverage data and is the default; see
31*08b48e0bSAndroid Build Coastguard Worker   [instrumentation/README.llvm.md](../instrumentation/README.llvm.md).
32*08b48e0bSAndroid Build Coastguard Worker
33*08b48e0bSAndroid Build Coastguard WorkerC. Instead of forking, reiterate the fuzz target function in a loop (like
34*08b48e0bSAndroid Build Coastguard Worker   `LLVMFuzzerTestOneInput`. Great speed increase but only works with target
35*08b48e0bSAndroid Build Coastguard Worker   functions that do not keep state, leak memory, or exit; see
36*08b48e0bSAndroid Build Coastguard Worker   [instrumentation/README.persistent_mode.md](../instrumentation/README.persistent_mode.md)
37*08b48e0bSAndroid Build Coastguard Worker
38*08b48e0bSAndroid Build Coastguard WorkerD. Split any non-8-bit comparison to 8-bit comparison; see
39*08b48e0bSAndroid Build Coastguard Worker   [instrumentation/README.laf-intel.md](../instrumentation/README.laf-intel.md)
40*08b48e0bSAndroid Build Coastguard Worker
41*08b48e0bSAndroid Build Coastguard WorkerE. CmpLog is our enhanced
42*08b48e0bSAndroid Build Coastguard Worker   [Redqueen](https://www.ndss-symposium.org/ndss-paper/redqueen-fuzzing-with-input-to-state-correspondence/)
43*08b48e0bSAndroid Build Coastguard Worker   implementation, see
44*08b48e0bSAndroid Build Coastguard Worker   [instrumentation/README.cmplog.md](../instrumentation/README.cmplog.md)
45*08b48e0bSAndroid Build Coastguard Worker
46*08b48e0bSAndroid Build Coastguard WorkerF. Similar and compatible to clang 13+ sancov sanitize-coverage-allow/deny but
47*08b48e0bSAndroid Build Coastguard Worker   for all llvm versions and all our compile modes, only instrument what should
48*08b48e0bSAndroid Build Coastguard Worker   be instrumented, for more speed, directed fuzzing and less instability; see
49*08b48e0bSAndroid Build Coastguard Worker   [instrumentation/README.instrument_list.md](../instrumentation/README.instrument_list.md)
50*08b48e0bSAndroid Build Coastguard Worker
51*08b48e0bSAndroid Build Coastguard WorkerG. Vanilla AFL uses coverage where edges could collide to the same coverage
52*08b48e0bSAndroid Build Coastguard Worker   bytes the larger the target is. Our default instrumentation in LTO and
53*08b48e0bSAndroid Build Coastguard Worker   afl-clang-fast (PCGUARD) uses non-colliding coverage that also makes it
54*08b48e0bSAndroid Build Coastguard Worker   faster. Vanilla AFL style is available with `AFL_LLVM_INSTRUMENT=AFL`; see
55*08b48e0bSAndroid Build Coastguard Worker   [instrumentation/README.llvm.md](../instrumentation/README.llvm.md).
56*08b48e0bSAndroid Build Coastguard Worker
57*08b48e0bSAndroid Build Coastguard WorkerH.+I. Alternative coverage based on previous edges (NGRAM) or depending on the
58*08b48e0bSAndroid Build Coastguard Worker   caller (CTX), based on
59*08b48e0bSAndroid Build Coastguard Worker   [https://www.usenix.org/system/files/raid2019-wang-jinghan.pdf](https://www.usenix.org/system/files/raid2019-wang-jinghan.pdf);
60*08b48e0bSAndroid Build Coastguard Worker   see [instrumentation/README.llvm.md](../instrumentation/README.llvm.md).
61*08b48e0bSAndroid Build Coastguard Worker
62*08b48e0bSAndroid Build Coastguard WorkerJ. An LTO feature that creates a fuzzing dictionary based on comparisons found
63*08b48e0bSAndroid Build Coastguard Worker   during compilation/instrumentation. Automatic feature :) See
64*08b48e0bSAndroid Build Coastguard Worker   [instrumentation/README.lto.md](../instrumentation/README.lto.md)
65*08b48e0bSAndroid Build Coastguard Worker
66*08b48e0bSAndroid Build Coastguard WorkerK. The snapshot feature requires a kernel module that was a lot of work to get
67*08b48e0bSAndroid Build Coastguard Worker   right and maintained so it is no longer supported. We have
68*08b48e0bSAndroid Build Coastguard Worker   [nyx_mode](../nyx_mode/README.md) instead.
69*08b48e0bSAndroid Build Coastguard Worker
70*08b48e0bSAndroid Build Coastguard WorkerL. Faster fuzzing and less kernel syscall overhead by in-memory fuzz testcase
71*08b48e0bSAndroid Build Coastguard Worker   delivery, see
72*08b48e0bSAndroid Build Coastguard Worker   [instrumentation/README.persistent_mode.md](../instrumentation/README.persistent_mode.md)
73*08b48e0bSAndroid Build Coastguard Worker
74*08b48e0bSAndroid Build Coastguard Worker## More information about instrumentation
75*08b48e0bSAndroid Build Coastguard Worker
76*08b48e0bSAndroid Build Coastguard Worker1. Default for LLVM >= 9.0, environment variable for older version due an
77*08b48e0bSAndroid Build Coastguard Worker   efficiency bug in previous llvm versions
78*08b48e0bSAndroid Build Coastguard Worker2. GCC creates non-performant code, hence it is disabled in gcc_plugin
79*08b48e0bSAndroid Build Coastguard Worker3. With `AFL_LLVM_THREADSAFE_INST`, disables NeverZero
80*08b48e0bSAndroid Build Coastguard Worker4. With pcguard mode and LTO mode for LLVM 11 and newer
81*08b48e0bSAndroid Build Coastguard Worker5. Upcoming, development in the branch
82*08b48e0bSAndroid Build Coastguard Worker6. Not compatible with LTO instrumentation and needs at least LLVM v4.1
83*08b48e0bSAndroid Build Coastguard Worker7. Automatic in LTO mode with LLVM 11 and newer, an extra pass for all LLVM
84*08b48e0bSAndroid Build Coastguard Worker   versions that write to a file to use with afl-fuzz' `-x`
85*08b48e0bSAndroid Build Coastguard Worker8. The snapshot LKM is currently unmaintained due to too many kernel changes
86*08b48e0bSAndroid Build Coastguard Worker   coming too fast :-(
87*08b48e0bSAndroid Build Coastguard Worker9. FRIDA mode is supported on Linux and MacOS for Intel and ARM
88*08b48e0bSAndroid Build Coastguard Worker10. QEMU/Unicorn is only supported on Linux
89*08b48e0bSAndroid Build Coastguard Worker11. Coresight mode is only available on AARCH64 Linux with a CPU with Coresight
90*08b48e0bSAndroid Build Coastguard Worker    extension
91*08b48e0bSAndroid Build Coastguard Worker12. Nyx mode is only supported on Linux and currently restricted to x86_x64
92*08b48e0bSAndroid Build Coastguard Worker
93*08b48e0bSAndroid Build Coastguard Worker## Integrated features and patches
94*08b48e0bSAndroid Build Coastguard Worker
95*08b48e0bSAndroid Build Coastguard WorkerAmong others, the following features and patches have been integrated:
96*08b48e0bSAndroid Build Coastguard Worker
97*08b48e0bSAndroid Build Coastguard Worker* NeverZero patch for afl-gcc, instrumentation, QEMU mode and unicorn_mode which
98*08b48e0bSAndroid Build Coastguard Worker  prevents a wrapping map value to zero, increases coverage
99*08b48e0bSAndroid Build Coastguard Worker* Persistent mode, deferred forkserver and in-memory fuzzing for QEMU mode
100*08b48e0bSAndroid Build Coastguard Worker* Unicorn mode which allows fuzzing of binaries from completely different
101*08b48e0bSAndroid Build Coastguard Worker  platforms (integration provided by domenukk)
102*08b48e0bSAndroid Build Coastguard Worker* The new CmpLog instrumentation for LLVM and QEMU inspired by
103*08b48e0bSAndroid Build Coastguard Worker  [Redqueen](https://github.com/RUB-SysSec/redqueen)
104*08b48e0bSAndroid Build Coastguard Worker* Win32 PE binary-only fuzzing with QEMU and Wine
105*08b48e0bSAndroid Build Coastguard Worker* AFLfast's power schedules by Marcel Böhme:
106*08b48e0bSAndroid Build Coastguard Worker  [https://github.com/mboehme/aflfast](https://github.com/mboehme/aflfast)
107*08b48e0bSAndroid Build Coastguard Worker* The MOpt mutator:
108*08b48e0bSAndroid Build Coastguard Worker  [https://github.com/puppet-meteor/MOpt-AFL](https://github.com/puppet-meteor/MOpt-AFL)
109*08b48e0bSAndroid Build Coastguard Worker* LLVM mode Ngram coverage by Adrian Herrera
110*08b48e0bSAndroid Build Coastguard Worker  [https://github.com/adrianherrera/afl-ngram-pass](https://github.com/adrianherrera/afl-ngram-pass)
111*08b48e0bSAndroid Build Coastguard Worker* LAF-Intel/CompCov support for instrumentation, QEMU mode and unicorn_mode
112*08b48e0bSAndroid Build Coastguard Worker  (with enhanced capabilities)
113*08b48e0bSAndroid Build Coastguard Worker* Radamsa and honggfuzz mutators (as custom mutators).
114*08b48e0bSAndroid Build Coastguard Worker* QBDI mode to fuzz android native libraries via Quarkslab's
115*08b48e0bSAndroid Build Coastguard Worker  [QBDI](https://github.com/QBDI/QBDI) framework
116*08b48e0bSAndroid Build Coastguard Worker* Frida and ptrace mode to fuzz binary-only libraries, etc.
117*08b48e0bSAndroid Build Coastguard Worker
118*08b48e0bSAndroid Build Coastguard WorkerSo all in all this is the best-of AFL that is out there :-)