Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: third_party/afl/src/docs/env_variables.txt

Issue 2075883002: Add American Fuzzy Lop (afl) to third_party/afl/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/afl/src/docs/README ('k') | third_party/afl/src/docs/historical_notes.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 =======================
2 Environmental variables
3 =======================
4
5 This document discusses the environment variables used by American Fuzzy Lop
6 to expose various exotic functions that may be (rarely) useful for power
7 users or for some types of custom fuzzing setups. See README for the general
8 instruction manual.
9
10 1) Settings for afl-gcc, afl-clang, and afl-as
11 ----------------------------------------------
12
13 Because they can't directly accept command-line options, the compile-time
14 tools make fairly broad use of environmental variables:
15
16 - Setting AFL_HARDEN automatically adds code hardening options when invoking
17 the downstream compiler. This currently includes -D_FORTIFY_SOURCE=2 and
18 -fstack-protector-all. The setting is useful for catching non-crashing
19 memory bugs at the expense of a very slight (sub-5%) performance loss.
20
21 - By default, the wrapper appends -O3 to optimize builds. Very rarely, this
22 will cause problems in programs built with -Werror, simply because -O3
23 enables more thorough code analysis and can spew out additional warnings.
24 To disable optimizations, set AFL_DONT_OPTIMIZE.
25
26 - Setting AFL_USE_ASAN automatically enables ASAN, provided that your
27 compiler supports that. Note that fuzzing with ASAN is mildly challenging
28 - see notes_for_asan.txt.
29
30 (You can also enable MSAN via AFL_USE_MSAN; ASAN and MSAN come with the
31 same gotchas; the modes are mutually exclusive. UBSAN and other exotic
32 sanitizers are not officially supported yet, but are easy to get to work
33 by hand.)
34
35 - Setting AFL_CC, AFL_CXX, and AFL_AS lets you use alternate downstream
36 compilation tools, rather than the default 'clang', 'gcc', or 'as' binaries
37 in your $PATH.
38
39 - AFL_PATH can be used to point afl-gcc to an alternate location of afl-as.
40 One possible use of this is experimental/clang_asm_normalize/, which lets
41 you instrument hand-written assembly when compiling clang code by plugging
42 a normalizer into the chain. (There is no equivalent feature for GCC.)
43
44 - Setting AFL_INST_RATIO to a percentage between 0 and 100% controls the
45 probability of instrumenting every branch. This is (very rarely) useful
46 when dealing with exceptionally complex programs that saturate the output
47 bitmap. Examples include v8, ffmpeg, and perl.
48
49 (If this ever happens, afl-fuzz will warn you ahead of the time by
50 displaying the "bitmap density" field in fiery red.)
51
52 Setting AFL_INST_RATIO to 0 is a valid choice. This will instrument only
53 the transitions between function entry points, but not individual branches.
54
55 - TMPDIR is used by afl-as for temporary files; if this variable is not set,
56 the tool defaults to /tmp.
57
58 - Setting AFL_KEEP_ASSEMBLY prevents afl-as from deleting instrumented
59 assembly files. Useful for troubleshooting problems or understanding how
60 the tool works. To get them in a predictable place, try something like:
61
62 mkdir assembly_here
63 TMPDIR=$PWD/assembly_here AFL_KEEP_ASSEMBLY=1 make clean all
64
65 - Setting AFL_QUIET will prevent afl-cc and afl-as banners from being
66 displayed during compilation, in case you find them distracting.
67
68 2) Settings for afl-clang-fast
69 ------------------------------
70
71 The native LLVM instrumentation helper accepts a subset of the settings
72 discussed in section #1, with the exception of:
73
74 - AFL_AS, since this toolchain does not directly invoke GNU as.
75
76 - TMPDIR and AFL_KEEP_ASSEMBLY, since no temporary assembly files are
77 created.
78
79 Note that AFL_INST_RATIO will behave a bit differently than for afl-gcc,
80 because functions are *not* instrumented unconditionally - so low values
81 will have a more striking effect. For this tool, 0 is not a valid choice.
82
83 3) Settings for afl-fuzz
84 ------------------------
85
86 The main fuzzer binary accepts several options that disable a couple of sanity
87 checks or alter some of the more exotic semantics of the tool:
88
89 - Setting AFL_SKIP_CPUFREQ skips the check for CPU scaling policy. This is
90 useful if you can't change the defaults (e.g., no root access to the
91 system) and are OK with some performance loss.
92
93 - Setting AFL_NO_FORKSRV disables the forkserver optimization, reverting to
94 fork + execve() call for every tested input. This is useful mostly when
95 working with unruly libraries that create threads or do other crazy
96 things when initializing (before the instrumentation has a chance to run).
97
98 Note that this setting inhibits some of the user-friendly diagnostics
99 normally done when starting up the forkserver and causes a pretty
100 significant performance drop.
101
102 - Setting AFL_NO_VAR_CHECK skips the detection of variable test cases,
103 greatly speeding up session resumption and path discovery for complex
104 multi-threaded apps (but depriving you of a potentially useful signal
105 in more orderly programs).
106
107 - AFL_EXIT_WHEN_DONE causes afl-fuzz to terminate when all existing paths
108 have been fuzzed and there were no new finds for a while. This would be
109 normally indicated by the cycle counter in the UI turning green. May be
110 convenient for some types of automated jobs.
111
112 - AFL_SKIP_CRASHES causes AFL to tolerate crashing files in the input
113 queue. This can help with rare situations where a program crashes only
114 intermittently, but it's not really recommended under normal operating
115 conditions.
116
117 - AFL_SHUFFLE_QUEUE randomly reorders the input queue on startup. Requested
118 by some users for unorthodox parallelized fuzzing setups, but not
119 advisable otherwise.
120
121 - When developing custom instrumentation on top of afl-fuzz, you can use
122 AFL_SKIP_BIN_CHECK to inhibit the checks for non-instrumented binaries
123 and shell scripts; and AFL_DUMB_FORKSRV in conjunction with the -n
124 setting to instruct afl-fuzz to still follow the fork server protocol
125 without expecting any instrumentation data in return.
126
127 - When running in the -M or -S mode, setting AFL_IMPORT_FIRST causes the
128 fuzzer to import test cases from other instances before doing anything
129 else. This makes the "own finds" counter in the UI more accurate.
130 Beyond counter aesthetics, not much else should change.
131
132 - Setting AFL_POST_LIBRARY allows you to configure a postprocessor for
133 mutated files - say, to fix up checksums. See experimental/post_library/
134 for more.
135
136 - The CPU widget shown at the bottom of the screen is fairly simplistic and
137 may complain of high load prematurely, especially on systems with low core
138 counts. To avoid the alarming red color, you can set AFL_NO_CPU_RED.
139
140 - In QEMU mode (-Q), AFL_PATH will be searched for afl-qemu-trace.
141
142 - Setting AFL_LD_PRELOAD causes AFL to set LD_PRELOAD for the target binary
143 without disrupting the afl-fuzz process itself.
144
145 - If you are Jakub, you may need AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES.
146 Others need not apply.
147
148 - Benchmarking only: AFL_BENCH_JUST_ONE causes the fuzzer to exit after
149 processing the first queue entry; and AFL_BENCH_UNTIL_CRASH causes it to
150 exit when first crash is found.
151
152 4) Settings for afl-qemu-trace
153 ------------------------------
154
155 The QEMU wrapper used to instrument binary-only code supports several settings:
156
157 - It is possible to set AFL_INST_RATIO to skip the instrumentation on some
158 of the basic blocks, which can be useful when dealing with very complex
159 binaries.
160
161 - Setting AFL_INST_LIBS causes the translator to also instrument the code
162 inside any dynamically linked libraries (notably including glibc).
163
164 - The underlying QEMU binary will recognize any standard "user space
165 emulation" variables (e.g., QEMU_STACK_SIZE), but there should be no
166 reason to touch them.
167
168 5) Settings for afl-cmin
169 ------------------------
170
171 The corpus minimization script offers very little customization:
172
173 - Setting AFL_PATH offers a way to specify the location of afl-showmap
174 and afl-qemu-trace (the latter only in -Q mode).
175
176 - AFL_KEEP_TRACES makes the tool keep traces and other metadata used for
177 minimization and normally deleted at exit. The files can be found in the
178 <out_dir>/.traces/*.
179
180 6) Settings for afl-tmin
181 ------------------------
182
183 Virtually nothing to play with. Well, in QEMU mode (-Q), AFL_PATH will be
184 searched for afl-qemu-trace. In addition to this, TMPDIR may be used if a
185 temporary file can't be created in the current working directory.
186
187 7) Third-party variables set by afl-fuzz & other tools
188 ------------------------------------------------------
189
190 Several variables are not directly interpreted by afl-fuzz, but are set to
191 optimal values if not already present in the environment:
192
193 - By default, LD_BIND_NOW is set to speed up fuzzing by forcing the
194 linker to do all the work before the fork server kicks in. You can
195 override this by setting LD_BIND_LAZY beforehand, but it is almost
196 certainly pointless.
197
198 - By default, ASAN_OPTIONS are set to:
199
200 abort_on_error=1
201 detect_leaks=0
202 symbolize=0
203 allocator_may_return_null=1
204
205 If you want to set your own options, be sure to include abort_on_error=1 -
206 otherwise, the fuzzer will not be able to detect crashes in the tested
207 app. Similarly, include symbolize=0, since without it, AFL may have
208 difficulty telling crashes and hangs apart.
209
210 - In the same vein, by default, MSAN_OPTIONS are set to:
211
212 exit_code=86 (required for legacy reasons)
213 abort_on_error=1
214 symbolize=0
215 msan_track_origins=0
216 allocator_may_return_null=1
217
218 Be sure to include the first one when customizing anything, since MSAN
219 doesn't call abort() on error, and we need a way to detect faults.
OLDNEW
« no previous file with comments | « third_party/afl/src/docs/README ('k') | third_party/afl/src/docs/historical_notes.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698