xref: /aosp_15_r20/external/cronet/testing/libfuzzer/efficient_fuzzing.md (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1*6777b538SAndroid Build Coastguard Worker# Efficient Fuzzing Guide
2*6777b538SAndroid Build Coastguard Worker
3*6777b538SAndroid Build Coastguard WorkerThis relates to fuzzers created using [libfuzzer] not [FuzzTests] - none of this
4*6777b538SAndroid Build Coastguard Workeradvice is necessary for FuzzTests.
5*6777b538SAndroid Build Coastguard Worker
6*6777b538SAndroid Build Coastguard WorkerOnce you have a fuzz target running, you can analyze and tweak it to improve its
7*6777b538SAndroid Build Coastguard Workerefficiency. This document describes techniques to minimize fuzzing time and
8*6777b538SAndroid Build Coastguard Workermaximize your results.
9*6777b538SAndroid Build Coastguard Worker
10*6777b538SAndroid Build Coastguard Worker*** note
11*6777b538SAndroid Build Coastguard Worker**Note:** If you haven’t created your first fuzz target yet, see the [Getting
12*6777b538SAndroid Build Coastguard WorkerStarted Guide].
13*6777b538SAndroid Build Coastguard Worker***
14*6777b538SAndroid Build Coastguard Worker
15*6777b538SAndroid Build Coastguard WorkerThe most direct way to gauge the effectiveness of your fuzz target is to collect
16*6777b538SAndroid Build Coastguard Workermetrics. You can get them manually, or take them from a [ClusterFuzz status]
17*6777b538SAndroid Build Coastguard Workerpage after your fuzz target is checked into the Chromium repository.
18*6777b538SAndroid Build Coastguard Worker
19*6777b538SAndroid Build Coastguard Worker[TOC]
20*6777b538SAndroid Build Coastguard Worker
21*6777b538SAndroid Build Coastguard Worker## Key metrics of a fuzz target
22*6777b538SAndroid Build Coastguard Worker
23*6777b538SAndroid Build Coastguard Worker### Execution speed
24*6777b538SAndroid Build Coastguard Worker
25*6777b538SAndroid Build Coastguard WorkerA fuzzing engine such as libFuzzer typically explores a large search space by
26*6777b538SAndroid Build Coastguard Workerperforming randomized mutations, so it needs to run as fast as possible to find
27*6777b538SAndroid Build Coastguard Workerinteresting code paths.
28*6777b538SAndroid Build Coastguard Worker
29*6777b538SAndroid Build Coastguard WorkerFuzz target speed is calculated in executions per second (`exec/s`). It is
30*6777b538SAndroid Build Coastguard Workerprinted while a fuzz target is running:
31*6777b538SAndroid Build Coastguard Worker
32*6777b538SAndroid Build Coastguard Worker```
33*6777b538SAndroid Build Coastguard Worker#11002  NEW    cov: 1337 ft: 10934 corp: 707/409Kb lim: 1098 exec/s: 5333 rss: 27Mb L: 186/1098
34*6777b538SAndroid Build Coastguard Worker```
35*6777b538SAndroid Build Coastguard Worker
36*6777b538SAndroid Build Coastguard WorkerYou should aim for at least 1,000 exec/s from your fuzz target locally before
37*6777b538SAndroid Build Coastguard Workersubmitting it to the Chromium repository. If you’re under 1,000, consider the
38*6777b538SAndroid Build Coastguard Workerfollowing improvements:
39*6777b538SAndroid Build Coastguard Worker
40*6777b538SAndroid Build Coastguard Worker* [Simplifying initialization/cleanup](#Simplifying-initialization-cleanup)
41*6777b538SAndroid Build Coastguard Worker* [Minimizing memory usage](#Minimizing-memory-usage)
42*6777b538SAndroid Build Coastguard Worker
43*6777b538SAndroid Build Coastguard Worker#### Simplifying initialization/cleanup
44*6777b538SAndroid Build Coastguard Worker
45*6777b538SAndroid Build Coastguard WorkerIf your `LLVMFuzzerTestOneInput` function is too complex, it can decrease the
46*6777b538SAndroid Build Coastguard Workerfuzzer’s execution speed. It can also cause the fuzzer to target specific
47*6777b538SAndroid Build Coastguard Workeruse-cases or fail to account for unexpected scenarios.
48*6777b538SAndroid Build Coastguard Worker
49*6777b538SAndroid Build Coastguard WorkerInstead of performing setup and teardown on each input, use static
50*6777b538SAndroid Build Coastguard Workerinitialization and shared resources. Check out this [startup initialization] in
51*6777b538SAndroid Build Coastguard WorkerlibFuzzer’s documentation for an example.
52*6777b538SAndroid Build Coastguard Worker
53*6777b538SAndroid Build Coastguard Worker*** note
54*6777b538SAndroid Build Coastguard Worker**Note:** You can skip freeing static resources. However, all other resources
55*6777b538SAndroid Build Coastguard Workerallocated within the `LLVMFuzzerTestOneInput` function should be de-allocated,
56*6777b538SAndroid Build Coastguard Workersince the function gets called millions of times during a fuzzing session. If
57*6777b538SAndroid Build Coastguard Workeryou don’t, you’ll often run out of memory and reduce overall fuzzing efficiency.
58*6777b538SAndroid Build Coastguard Worker***
59*6777b538SAndroid Build Coastguard Worker
60*6777b538SAndroid Build Coastguard Worker#### Minimizing memory usage
61*6777b538SAndroid Build Coastguard Worker
62*6777b538SAndroid Build Coastguard WorkerAvoid allocation of dynamic memory wherever possible. Memory instrumentation
63*6777b538SAndroid Build Coastguard Workerworks faster for stack-based and static objects than for heap-allocated ones.
64*6777b538SAndroid Build Coastguard Worker
65*6777b538SAndroid Build Coastguard Worker*** note
66*6777b538SAndroid Build Coastguard Worker**Note:** It’s always a good idea to try different variants for your fuzz target
67*6777b538SAndroid Build Coastguard Workerlocally, then submit only the fastest implementation to the Chromium repository.
68*6777b538SAndroid Build Coastguard Worker***
69*6777b538SAndroid Build Coastguard Worker
70*6777b538SAndroid Build Coastguard Worker### Code coverage
71*6777b538SAndroid Build Coastguard Worker
72*6777b538SAndroid Build Coastguard WorkerYou can check the percentage of code covered by your fuzz target to gauge
73*6777b538SAndroid Build Coastguard Workerfuzzing effectiveness:
74*6777b538SAndroid Build Coastguard Worker
75*6777b538SAndroid Build Coastguard Worker* Review aggregated Chrome coverage from recent runs by checking the [fuzzing
76*6777b538SAndroid Build Coastguard Worker  coverage] report. This report can provide insight on how to improve code
77*6777b538SAndroid Build Coastguard Worker  coverage.
78*6777b538SAndroid Build Coastguard Worker* Generate a source-level coverage report for your fuzzer by running the
79*6777b538SAndroid Build Coastguard Worker  [coverage script] stored in the Chromium repository. The script provides
80*6777b538SAndroid Build Coastguard Worker  detailed instructions and a usage example.
81*6777b538SAndroid Build Coastguard Worker
82*6777b538SAndroid Build Coastguard WorkerFor the `out/coverage` target in the coverage script, make sure to add all of
83*6777b538SAndroid Build Coastguard Workerthe gn args you needed to build the `out/libfuzzer` target; this could include
84*6777b538SAndroid Build Coastguard Workerargs like `target_os=chromeos` and `is_asan=true` depending on the [gn config]
85*6777b538SAndroid Build Coastguard Workeryou chose.
86*6777b538SAndroid Build Coastguard Worker
87*6777b538SAndroid Build Coastguard Worker*** note
88*6777b538SAndroid Build Coastguard Worker**Note:** The code coverage of a fuzz target depends heavily on the corpus. A
89*6777b538SAndroid Build Coastguard Workerwell-chosen corpus will produce much greater code coverage. On the other hand,
90*6777b538SAndroid Build Coastguard Workera coverage report generated by a fuzz target without a corpus won't cover much
91*6777b538SAndroid Build Coastguard Workercode. If you don’t have a corpus to use, you can download the [corpus from
92*6777b538SAndroid Build Coastguard WorkerClusterFuzz]. For more information on the corpus, see
93*6777b538SAndroid Build Coastguard Worker[Corpus Size](#Corpus-Size).
94*6777b538SAndroid Build Coastguard Worker***
95*6777b538SAndroid Build Coastguard Worker
96*6777b538SAndroid Build Coastguard Worker### Corpus size
97*6777b538SAndroid Build Coastguard Worker
98*6777b538SAndroid Build Coastguard WorkerA guided fuzzing engine such as libFuzzer considers an input (a.k.a. testcase
99*6777b538SAndroid Build Coastguard Workeror corpus unit) *interesting* if the input results in new code coverage (i.e.,
100*6777b538SAndroid Build Coastguard Workerif the fuzzer reaches code that has not been reached before). The set of all
101*6777b538SAndroid Build Coastguard Workerinteresting inputs is called the *corpus*. A corpus is shared across fuzzer runs
102*6777b538SAndroid Build Coastguard Workerand grows over time.
103*6777b538SAndroid Build Coastguard Worker
104*6777b538SAndroid Build Coastguard WorkerIf a fuzz target stops discovering new interesting inputs after running for a
105*6777b538SAndroid Build Coastguard Workerwhile, it typically indicates that the fuzz target is hitting a code barrier
106*6777b538SAndroid Build Coastguard Worker(also called a *coverage plateau*). The corpus for a reasonably complex target
107*6777b538SAndroid Build Coastguard Workershould contain hundreds (if not thousands) of inputs.
108*6777b538SAndroid Build Coastguard Worker
109*6777b538SAndroid Build Coastguard WorkerIf a fuzz target reaches coverage plateau with a small corpus, the common causes
110*6777b538SAndroid Build Coastguard Workerare checksums and magic numbers. Or, it may be impossible for your fuzzer to
111*6777b538SAndroid Build Coastguard Workerreach a lot of code. The easiest way to diagnose the problem is to generate and
112*6777b538SAndroid Build Coastguard Workeranalyze a [coverage report](#code-coverage). Then, to fix the issue, try the
113*6777b538SAndroid Build Coastguard Workerfollowing:
114*6777b538SAndroid Build Coastguard Worker
115*6777b538SAndroid Build Coastguard Worker* Change the code (e.g., disable CRC checks while fuzzing) with a
116*6777b538SAndroid Build Coastguard Worker  [custom build](#Custom-build).
117*6777b538SAndroid Build Coastguard Worker* Prepare or improve the [seed corpus](#Seed-corpus).
118*6777b538SAndroid Build Coastguard Worker* Prepare or improve the [fuzzer dictionary](#Fuzzer-dictionary).
119*6777b538SAndroid Build Coastguard Worker
120*6777b538SAndroid Build Coastguard Worker## Ways to improve a fuzz target
121*6777b538SAndroid Build Coastguard Worker
122*6777b538SAndroid Build Coastguard Worker### Seed corpus
123*6777b538SAndroid Build Coastguard Worker
124*6777b538SAndroid Build Coastguard WorkerYou can give your fuzz target a starting point by creating a set of valid and
125*6777b538SAndroid Build Coastguard Workerinteresting inputs called a *seed corpus*. If you don’t provide a seed corpus,
126*6777b538SAndroid Build Coastguard Workerthe fuzzing engine has to guess inputs from scratch, which can take time
127*6777b538SAndroid Build Coastguard Worker(depending on the size of the inputs and the complexity of the target format).
128*6777b538SAndroid Build Coastguard WorkerIn many cases, providing a seed corpus can increase code coverage by an order of
129*6777b538SAndroid Build Coastguard Workermagnitude.
130*6777b538SAndroid Build Coastguard Worker
131*6777b538SAndroid Build Coastguard WorkerSeed corpuses work especially well for strictly defined file formats and data
132*6777b538SAndroid Build Coastguard Workertransmission protocols:
133*6777b538SAndroid Build Coastguard Worker
134*6777b538SAndroid Build Coastguard Worker* For file format parsers, add valid files from your test suite.
135*6777b538SAndroid Build Coastguard Worker* For protocol parsers, add valid raw streams from a test suite into separate
136*6777b538SAndroid Build Coastguard Worker  files.
137*6777b538SAndroid Build Coastguard Worker* For graphics libraries, add a variety of small PNG/JPG/GIF files.
138*6777b538SAndroid Build Coastguard Worker
139*6777b538SAndroid Build Coastguard Worker#### Using a corpus locally
140*6777b538SAndroid Build Coastguard Worker
141*6777b538SAndroid Build Coastguard WorkerIf you’re running a fuzz target locally, you can easily designate a corpus by
142*6777b538SAndroid Build Coastguard Workerpassing a directory as an argument:
143*6777b538SAndroid Build Coastguard Worker
144*6777b538SAndroid Build Coastguard Worker```
145*6777b538SAndroid Build Coastguard Worker./out/libfuzzer/my_fuzzer ~/tmp/my_fuzzer_corpus
146*6777b538SAndroid Build Coastguard Worker```
147*6777b538SAndroid Build Coastguard Worker
148*6777b538SAndroid Build Coastguard WorkerThe fuzzer stores all the interesting inputs it finds in the directory.
149*6777b538SAndroid Build Coastguard Worker
150*6777b538SAndroid Build Coastguard Worker#### Creating a Chromium repository seed corpus
151*6777b538SAndroid Build Coastguard Worker
152*6777b538SAndroid Build Coastguard WorkerWhen running fuzz targets at scale, ClusterFuzz looks for a seed corpus defined
153*6777b538SAndroid Build Coastguard Workerin the Chromium source repository. You can define one in your `BUILD.gn` file by
154*6777b538SAndroid Build Coastguard Workeradding a `seed_corpus` attribute to your `fuzzer_test` target definition:
155*6777b538SAndroid Build Coastguard Worker
156*6777b538SAndroid Build Coastguard Worker```
157*6777b538SAndroid Build Coastguard Workerfuzzer_test("my_fuzzer") {
158*6777b538SAndroid Build Coastguard Worker  ...
159*6777b538SAndroid Build Coastguard Worker  seed_corpus = "test/fuzz/testcases"
160*6777b538SAndroid Build Coastguard Worker  ...
161*6777b538SAndroid Build Coastguard Worker}
162*6777b538SAndroid Build Coastguard Worker```
163*6777b538SAndroid Build Coastguard Worker
164*6777b538SAndroid Build Coastguard WorkerIf you want to specify multiple seed corpus directories, use the `seed_corpuses`
165*6777b538SAndroid Build Coastguard Workerattribute instead:
166*6777b538SAndroid Build Coastguard Worker
167*6777b538SAndroid Build Coastguard Worker```
168*6777b538SAndroid Build Coastguard Workerfuzzer_test("my_fuzzer") {
169*6777b538SAndroid Build Coastguard Worker  ...
170*6777b538SAndroid Build Coastguard Worker  seed_corpuses = [ "test/fuzz/testcases", "test/unittest/data" ]
171*6777b538SAndroid Build Coastguard Worker  ...
172*6777b538SAndroid Build Coastguard Worker}
173*6777b538SAndroid Build Coastguard Worker```
174*6777b538SAndroid Build Coastguard Worker
175*6777b538SAndroid Build Coastguard WorkerAll files found in these directories and their subdirectories are stored in a
176*6777b538SAndroid Build Coastguard Worker`<my_fuzzer>_seed_corpus.zip` output archive.
177*6777b538SAndroid Build Coastguard Worker
178*6777b538SAndroid Build Coastguard Worker#### Uploading corpus files to GCS
179*6777b538SAndroid Build Coastguard Worker
180*6777b538SAndroid Build Coastguard WorkerIf you can't store your seed corpus in the Chromium repository (e.g., it’s too
181*6777b538SAndroid Build Coastguard Workerlarge, can’t be open-sourced, etc.), you can upload the corpus to the Google
182*6777b538SAndroid Build Coastguard WorkerCloud Storage (GCS) bucket used by ClusterFuzz.
183*6777b538SAndroid Build Coastguard Worker
184*6777b538SAndroid Build Coastguard Worker1) Open the [Corpus GCS Bucket] in your browser.
185*6777b538SAndroid Build Coastguard Worker2) Search for the directory named `<my_fuzzer>`. If the directory does not
186*6777b538SAndroid Build Coastguard Worker   exist, create it.
187*6777b538SAndroid Build Coastguard Worker3) In the `<my_fuzzer>` directory, upload your corpus files.
188*6777b538SAndroid Build Coastguard Worker
189*6777b538SAndroid Build Coastguard Worker*** note
190*6777b538SAndroid Build Coastguard Worker**Note:** If you upload your corpus to GCS, you don’t need to add the
191*6777b538SAndroid Build Coastguard Worker`seed_corpus` attribute to your `fuzzer_test` target definition. However, adding
192*6777b538SAndroid Build Coastguard Workerseed corpus to the Chromium repository is the preferred way.
193*6777b538SAndroid Build Coastguard Worker***
194*6777b538SAndroid Build Coastguard Worker
195*6777b538SAndroid Build Coastguard WorkerYou can do the same thing by using the [gsutil] command line tool:
196*6777b538SAndroid Build Coastguard Worker
197*6777b538SAndroid Build Coastguard Worker```bash
198*6777b538SAndroid Build Coastguard Workergsutil -m rsync <path_to_corpus> gs://clusterfuzz-corpus/libfuzzer/<my_fuzzer>
199*6777b538SAndroid Build Coastguard Worker```
200*6777b538SAndroid Build Coastguard Worker
201*6777b538SAndroid Build Coastguard Worker*** note
202*6777b538SAndroid Build Coastguard Worker**Note:** To write to this bucket using `gsutil`, you must be logged into your
203*6777b538SAndroid Build Coastguard Worker@google.com account (@chromium.org will not work). You can use the `gcloud auth
204*6777b538SAndroid Build Coastguard Workerlogin` command to log into your account in `gsutil` if you installed `gsutil`
205*6777b538SAndroid Build Coastguard Workerthrough `gcloud`.
206*6777b538SAndroid Build Coastguard Worker***
207*6777b538SAndroid Build Coastguard Worker
208*6777b538SAndroid Build Coastguard Worker#### Minimizing a seed corpus
209*6777b538SAndroid Build Coastguard Worker
210*6777b538SAndroid Build Coastguard WorkerYour seed corpus is synced to all fuzzing bots for every iteration, so it's
211*6777b538SAndroid Build Coastguard Workerimportant to minimize it to a small set of interesting inputs before uploading.
212*6777b538SAndroid Build Coastguard WorkerKeeping the seed corpus small improves fuzzing efficiency and prevents our bots
213*6777b538SAndroid Build Coastguard Workerfrom running out of disk space.
214*6777b538SAndroid Build Coastguard Worker
215*6777b538SAndroid Build Coastguard WorkerYou can minimize your seed corpus by using libFuzzer’s `-merge=1` option:
216*6777b538SAndroid Build Coastguard Worker
217*6777b538SAndroid Build Coastguard Worker```bash
218*6777b538SAndroid Build Coastguard Worker# Create an empty directory.
219*6777b538SAndroid Build Coastguard Workermkdir seed_corpus_minimized
220*6777b538SAndroid Build Coastguard Worker
221*6777b538SAndroid Build Coastguard Worker# Run the fuzzer with -merge=1 flag.
222*6777b538SAndroid Build Coastguard Worker./my_fuzzer -merge=1 ./seed_corpus_minimized ./seed_corpus
223*6777b538SAndroid Build Coastguard Worker```
224*6777b538SAndroid Build Coastguard Worker
225*6777b538SAndroid Build Coastguard WorkerAfter running the command, the `seed_corpus_minimized` directory will contain a
226*6777b538SAndroid Build Coastguard Workerminimized corpus that gives the same code coverage as your initial `seed_corpus`
227*6777b538SAndroid Build Coastguard Workerdirectory.
228*6777b538SAndroid Build Coastguard Worker
229*6777b538SAndroid Build Coastguard Worker### Fuzzer dictionary
230*6777b538SAndroid Build Coastguard Worker
231*6777b538SAndroid Build Coastguard WorkerYou can help your fuzzer increase its coverage by providing a set of common
232*6777b538SAndroid Build Coastguard Workerwords or values that you expect to find in the input. Such a dictionary works
233*6777b538SAndroid Build Coastguard Workerespecially well for certain use-cases (e.g., fuzzing file format decoders or
234*6777b538SAndroid Build Coastguard Workertext-based protocols like XML).
235*6777b538SAndroid Build Coastguard Worker
236*6777b538SAndroid Build Coastguard WorkerAdd a fuzzer dictionary:
237*6777b538SAndroid Build Coastguard Worker
238*6777b538SAndroid Build Coastguard Worker1) Create a flat ASCII text file that lists one input token per line in the
239*6777b538SAndroid Build Coastguard Worker   format `name="value"`. The value must appear in quotes with hex escaping
240*6777b538SAndroid Build Coastguard Worker   (`\xNN`) applied to all non-printable, high-bit, or otherwise problematic
241*6777b538SAndroid Build Coastguard Worker   characters (`\` and `"` shorthands are recognized, too). This syntax is
242*6777b538SAndroid Build Coastguard Worker   similar to the one used by the [AFL] fuzzing engine (`-x` option).
243*6777b538SAndroid Build Coastguard Worker
244*6777b538SAndroid Build Coastguard Worker   *** note
245*6777b538SAndroid Build Coastguard Worker   **Note:** `name` can be omitted, but it is a convenient way to document the
246*6777b538SAndroid Build Coastguard Worker   meaning of each token. Here’s an example dictionary:
247*6777b538SAndroid Build Coastguard Worker   ***
248*6777b538SAndroid Build Coastguard Worker
249*6777b538SAndroid Build Coastguard Worker   ```
250*6777b538SAndroid Build Coastguard Worker   # Lines starting with '#' and empty lines are ignored.
251*6777b538SAndroid Build Coastguard Worker
252*6777b538SAndroid Build Coastguard Worker   # Adds "blah" word (w/o quotes) to the dictionary.
253*6777b538SAndroid Build Coastguard Worker   kw1="blah"
254*6777b538SAndroid Build Coastguard Worker   # Use \\ for backslash and \" for quotes.
255*6777b538SAndroid Build Coastguard Worker   kw2="\"ac\\dc\""
256*6777b538SAndroid Build Coastguard Worker   # Use \xAB for hex values.
257*6777b538SAndroid Build Coastguard Worker   kw3="\xF7\xF8"
258*6777b538SAndroid Build Coastguard Worker   # Key name before '=' can be omitted:
259*6777b538SAndroid Build Coastguard Worker   "foo\x0Abar"
260*6777b538SAndroid Build Coastguard Worker   ```
261*6777b538SAndroid Build Coastguard Worker
262*6777b538SAndroid Build Coastguard Worker2) Test your dictionary by running your fuzz target locally:
263*6777b538SAndroid Build Coastguard Worker
264*6777b538SAndroid Build Coastguard Worker   ```bash
265*6777b538SAndroid Build Coastguard Worker   ./out/libfuzzer/my_fuzzer -dict=<path_to_dict> <path_to_corpus>
266*6777b538SAndroid Build Coastguard Worker   ```
267*6777b538SAndroid Build Coastguard Worker
268*6777b538SAndroid Build Coastguard Worker   If the dictionary is effective, you should see `NEW` units discovered in the
269*6777b538SAndroid Build Coastguard Worker   output.
270*6777b538SAndroid Build Coastguard Worker
271*6777b538SAndroid Build Coastguard Worker3) Add the dictionary file in the same directory as your fuzz target, then add
272*6777b538SAndroid Build Coastguard Worker   the `dict` attribute to the `fuzzer_test` definition in your `BUILD.gn` file:
273*6777b538SAndroid Build Coastguard Worker
274*6777b538SAndroid Build Coastguard Worker   ```
275*6777b538SAndroid Build Coastguard Worker   fuzzer_test("my_fuzzer") {
276*6777b538SAndroid Build Coastguard Worker     ...
277*6777b538SAndroid Build Coastguard Worker     dict = "my_fuzzer.dict"
278*6777b538SAndroid Build Coastguard Worker   }
279*6777b538SAndroid Build Coastguard Worker   ```
280*6777b538SAndroid Build Coastguard Worker
281*6777b538SAndroid Build Coastguard Worker   The dictionary is submitted to the Chromium repository. Once ClusterFuzz
282*6777b538SAndroid Build Coastguard Worker   picks up a new revision build, the dictionary is used automatically.
283*6777b538SAndroid Build Coastguard Worker
284*6777b538SAndroid Build Coastguard Worker### Custom build
285*6777b538SAndroid Build Coastguard Worker
286*6777b538SAndroid Build Coastguard WorkerIf you need to change the code being tested by your fuzz target, you can use an
287*6777b538SAndroid Build Coastguard Worker`#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` macro in your target code.
288*6777b538SAndroid Build Coastguard Worker
289*6777b538SAndroid Build Coastguard Worker*** note
290*6777b538SAndroid Build Coastguard Worker**Note:** Patching target code is not a preferred way of improving the
291*6777b538SAndroid Build Coastguard Workercorresponding fuzz target, but in some cases it might be the only way to do it
292*6777b538SAndroid Build Coastguard Worker(e.g., when there is no intended API to disable checksum verification, or when
293*6777b538SAndroid Build Coastguard Workerthe target code uses a random generator that affects the reproducibility of
294*6777b538SAndroid Build Coastguard Workercrashes).
295*6777b538SAndroid Build Coastguard Worker***
296*6777b538SAndroid Build Coastguard Worker
297*6777b538SAndroid Build Coastguard Worker[AFL]: http://lcamtuf.coredump.cx/afl/
298*6777b538SAndroid Build Coastguard Worker[ClusterFuzz status]: libFuzzer_integration.md#Status-Links
299*6777b538SAndroid Build Coastguard Worker[Corpus GCS Bucket]: https://console.cloud.google.com/storage/clusterfuzz-corpus/libfuzzer
300*6777b538SAndroid Build Coastguard Worker[Getting Started Guide]: getting_started.md
301*6777b538SAndroid Build Coastguard Worker[gn config]: getting_started.md#running-the-fuzz-target
302*6777b538SAndroid Build Coastguard Worker[corpus from ClusterFuzz]: libFuzzer_integration.md#Corpus
303*6777b538SAndroid Build Coastguard Worker[coverage script]: https://cs.chromium.org/chromium/src/tools/code_coverage/coverage.py
304*6777b538SAndroid Build Coastguard Worker[fuzzing coverage]: https://analysis.chromium.org/coverage/p/chromium?platform=fuzz
305*6777b538SAndroid Build Coastguard Worker[gsutil]: https://cloud.google.com/storage/docs/gsutil
306*6777b538SAndroid Build Coastguard Worker[startup initialization]: https://llvm.org/docs/LibFuzzer.html#startup-initialization
307*6777b538SAndroid Build Coastguard Worker[libfuzzer]: getting_started_with_libfuzzer.md
308*6777b538SAndroid Build Coastguard Worker[fuzztests]: getting_started.md
309