[all-commits] [llvm/llvm-project] bb54bc: [libFuzzer] Fix arguments of InsertPartOf/CopyPart...
Dokyung Song via All-commits
all-commits at lists.llvm.org
Tue Aug 18 09:09:47 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: bb54bcf84970c04c9748004f3a4cf59b0c1832a7
https://github.com/llvm/llvm-project/commit/bb54bcf84970c04c9748004f3a4cf59b0c1832a7
Author: Dokyung Song <dokyungs at google.com>
Date: 2020-08-18 (Tue, 18 Aug 2020)
Changed paths:
M compiler-rt/lib/fuzzer/FuzzerMutate.cpp
M compiler-rt/test/fuzzer/CrossOverTest.cpp
M compiler-rt/test/fuzzer/cross_over.test
A compiler-rt/test/fuzzer/cross_over_copy.test
A compiler-rt/test/fuzzer/cross_over_insert.test
Log Message:
-----------
[libFuzzer] Fix arguments of InsertPartOf/CopyPartOf calls in CrossOver mutator.
The CrossOver mutator is meant to cross over two given buffers (referred to as
the first/second buffer henceforth). Previously InsertPartOf/CopyPartOf calls
used in the CrossOver mutator incorrectly inserted/copied part of the second
buffer into a "scratch buffer" (MutateInPlaceHere of the size
CurrentMaxMutationLen), rather than the first buffer. This is not intended
behavior, because the scratch buffer does not always (i) contain the content of
the first buffer, and (ii) have the same size as the first buffer;
CurrentMaxMutationLen is typically a lot larger than the size of the first
buffer. This patch fixes the issue by using the first buffer instead of the
scratch buffer in InsertPartOf/CopyPartOf calls.
A FuzzBench experiment was run to make sure that this change does not
inadvertently degrade the performance. The performance is largely the same; more
details can be found at:
https://storage.googleapis.com/fuzzer-test-suite-public/fixcrossover-report/index.html
This patch also adds two new tests, namely "cross_over_insert" and
"cross_over_copy", which specifically target InsertPartOf and CopyPartOf,
respectively.
- cross_over_insert.test checks if the fuzzer can use InsertPartOf to trigger
the crash.
- cross_over_copy.test checks if the fuzzer can use CopyPartOf to trigger the
crash.
These newly added tests were designed to pass with the current patch, but not
without the it (with 790878f291fa5dc58a1c560cb6cc76fd1bfd1c5a these tests do not
pass). To achieve this, -max_len was intentionally given a high value. Without
this patch, InsertPartOf/CopyPartOf will generate larger inputs, possibly with
unpredictable data in it, thereby failing to trigger the crash.
The test pass condition for these new tests is narrowed down by (i) limiting
mutation depth to 1 (i.e., a single CrossOver mutation should be able to trigger
the crash) and (ii) checking whether the mutation sequence of "CrossOver-" leads
to the crash.
Also note that these newly added tests and an existing test (cross_over.test)
all use "-reduce_inputs=0" flags to prevent reducing inputs; it's easier to
force the fuzzer to keep original input string this way than tweaking
cov-instrumented basic blocks in the source code of the fuzzer executable.
Differential Revision: https://reviews.llvm.org/D85554
More information about the All-commits
mailing list