llvm-project/compiler-rt/lib/fuzzer
Max Moroz f054067f27 [libFuzzer] Make -merge=1 to reuse coverage information from the control file.
Summary:
This change allows to perform corpus merging in two steps. This is useful when
the user wants to address the following two points simultaneously:

1) Get trustworthy incremental stats for the coverage and corpus size changes
    when adding new corpus units.
2) Make sure the shorter units will be preferred when two or more units give the
    same unique signal (equivalent to the `REDUCE` logic).

This solution was brainstormed together with @kcc, hopefully it looks good to
the other people too. The proposed use case scenario:

1) We have a `fuzz_target` binary and `existing_corpus` directory.
2) We do fuzzing and write new units into the `new_corpus` directory.
3) We want to merge the new corpus into the existing corpus and satisfy the
    points mentioned above.
4) We create an empty directory `merged_corpus` and run the first merge step:

    `
    ./fuzz_target -merge=1 -merge_control_file=MCF ./merged_corpus ./existing_corpus
    `

    this provides the initial stats for `existing_corpus`, e.g. from the output:

    `
    MERGE-OUTER: 3 new files with 11 new features added; 11 new coverage edges
    `

5) We recreate `merged_corpus` directory and run the second merge step:

    `
    ./fuzz_target -merge=1 -merge_control_file=MCF ./merged_corpus ./existing_corpus ./new_corpus
    `

    this provides the final stats for the merged corpus, e.g. from the output:

    `
    MERGE-OUTER: 6 new files with 14 new features added; 14 new coverage edges
    `

Alternative solutions to this approach are:

A) Store precise coverage information for every unit (not only unique signal).
B) Execute the same two steps without reusing the control file.

Either of these would be suboptimal as it would impose an extra disk or CPU load
respectively, which is bad given the quadratic complexity in the worst case.

Tested on Linux, Mac, Windows.

Reviewers: morehouse, metzman, hctim, kcc

Reviewed By: morehouse

Subscribers: JDevlieghere, delcypher, mgrang, #sanitizers, llvm-commits, kcc

Tags: #llvm, #sanitizers

Differential Revision: https://reviews.llvm.org/D66107

llvm-svn: 371620
2019-09-11 14:11:08 +00:00
..
afl Summary: 2019-04-18 18:49:11 +00:00
dataflow [libFuzzer] split DataFlow.cpp into two .cpp files, one of which can be compiled w/o dfsan to speed things up (~25% speedup) 2019-06-21 01:39:35 +00:00
scripts [libFuzzer] remove the data-flow-trace (DFT) python scripts; their functionality is now part of libFuzzer proper; also write functions.txt to the disk only if this file doesn't exist yet 2019-05-23 01:03:42 +00:00
standalone [libFuzzer] fix missing close on opened file 2019-02-26 19:33:00 +00:00
tests reland [gtest] Fix printing of StringRef and SmallString in assert messages. 2019-08-21 13:56:29 +00:00
utils [compiler-rt] Add ConsumeProbability and ConsumeFloatingPoint methods to FDP. 2019-08-08 19:49:37 +00:00
CMakeLists.txt Build libfuzzer libcxx-static with PIC 2019-08-05 22:55:17 +00:00
FuzzerBuiltins.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FuzzerBuiltinsMsvc.h LibFuzzer support for 32bit MSVC 2019-08-22 20:44:34 +00:00
FuzzerCommand.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FuzzerCorpus.h [libFuzzer] add -features_dir= flag to dump unique input features on disk 2019-04-13 00:20:31 +00:00
FuzzerCrossOver.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FuzzerDataFlowTrace.cpp [libFuzzer] in autofocus mode, give more weight to functions with DFT 2019-06-14 23:29:56 +00:00
FuzzerDataFlowTrace.h [libFuzzer] in autofocus mode, give more weight to functions with DFT 2019-06-14 23:29:56 +00:00
FuzzerDefs.h [libFuzzer] Make -merge=1 to reuse coverage information from the control file. 2019-09-11 14:11:08 +00:00
FuzzerDictionary.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FuzzerDriver.cpp [libFuzzer] implement a better queue for the fork mode. Add an internal flag -stop_file to allow graceful shutdown of fuzzing. Enhance the logging in the fork mode 2019-06-14 22:56:50 +00:00
FuzzerExtFunctions.def [compiler-rt] Move FDP to include/fuzzer/FuzzedDataProvider.h for easier use. 2019-08-05 19:55:52 +00:00
FuzzerExtFunctions.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FuzzerExtFunctionsDlsym.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FuzzerExtFunctionsWeak.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FuzzerExtFunctionsWindows.cpp [libFuzzer] Remove extra semicolons 2019-02-26 17:46:13 +00:00
FuzzerExtraCounters.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FuzzerFlags.def [libFuzzer] implement a better queue for the fork mode. Add an internal flag -stop_file to allow graceful shutdown of fuzzing. Enhance the logging in the fork mode 2019-06-14 22:56:50 +00:00
FuzzerFork.cpp [libFuzzer] implement a better queue for the fork mode. Add an internal flag -stop_file to allow graceful shutdown of fuzzing. Enhance the logging in the fork mode 2019-06-14 22:56:50 +00:00
FuzzerFork.h [libFuzzer] add threads to the fork mode: now you can pass -fork=N to run N concurrent workers. Fork mode is still work-in-progress. 2019-02-14 00:25:43 +00:00
FuzzerIO.cpp [libFuzzer] Replace -seed_corpus to better support fork mode on Win 2019-04-30 20:56:18 +00:00
FuzzerIO.h [libFuzzer] Replace -seed_corpus to better support fork mode on Win 2019-04-30 20:56:18 +00:00
FuzzerIOPosix.cpp [libFuzzer] add -features_dir= flag to dump unique input features on disk 2019-04-13 00:20:31 +00:00
FuzzerIOWindows.cpp [libFuzzer] add -features_dir= flag to dump unique input features on disk 2019-04-13 00:20:31 +00:00
FuzzerInterface.h [libFuzzer][Windows] Use dllexport for all declarations in FuzzerInterface.h 2019-01-28 17:51:13 +00:00
FuzzerInternal.h [libFuzzer] Merge: print feature coverage number as well. 2019-08-12 20:21:27 +00:00
FuzzerLoop.cpp [libFuzzer] Merge: print feature coverage number as well. 2019-08-12 20:21:27 +00:00
FuzzerMain.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FuzzerMerge.cpp [libFuzzer] Make -merge=1 to reuse coverage information from the control file. 2019-09-11 14:11:08 +00:00
FuzzerMerge.h [libFuzzer] fix the unit tests 2019-02-15 00:15:13 +00:00
FuzzerMutate.cpp [libFuzzer] Make MutateWithMask work when the Mask is shorter than the input. 2019-04-11 18:21:53 +00:00
FuzzerMutate.h [libFuzzer] refactor the way we choose the element to cross-over with, NFC (expected1); add a flag -seed_inputs= to pass extra seed inputs as file paths, not dirs 2019-02-08 01:20:54 +00:00
FuzzerOptions.h [libFuzzer] implement a better queue for the fork mode. Add an internal flag -stop_file to allow graceful shutdown of fuzzing. Enhance the logging in the fork mode 2019-06-14 22:56:50 +00:00
FuzzerRandom.h [libFuzzer] replace slow std::mt19937 with a much faster std::minstd_rand; second attempt after failed r352732, this time with a fix for cmake 2019-02-12 01:00:08 +00:00
FuzzerSHA1.cpp [libFuzzer][MSVC] Enable building libFuzzer with MSVC 2019-01-22 18:59:25 +00:00
FuzzerSHA1.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FuzzerTracePC.cpp compiler-rt: Rename .cc file in lib/sanitizer_common to .cpp 2019-07-31 18:51:27 +00:00
FuzzerTracePC.h [libFuzzer] print new functions as they are discovered in the fork mode 2019-02-15 01:22:00 +00:00
FuzzerUtil.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FuzzerUtil.h [libFuzzer] experimental performance optimization -lazy_counters, off by default. Posix-only for now, tested on Linux 2019-01-31 00:09:43 +00:00
FuzzerUtilDarwin.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FuzzerUtilFuchsia.cpp [libFuzzer] Migrate to the new exception syscalls on Fuchsia 2019-06-27 21:13:06 +00:00
FuzzerUtilLinux.cpp [libFuzzer] extend the -fork=1 functionality. Still not fully usable, but good enough for the first unit test 2019-02-12 00:12:33 +00:00
FuzzerUtilPosix.cpp [libFuzzer] set libFuzzer's own SEGV handler even one is already present, but call that handler from ours (unless we are unprotecting lazy counters). Call ProtectLazyCounters later, so that it runs after the initialization code in the target. 2019-01-31 01:40:14 +00:00
FuzzerUtilWindows.cpp [libFuzzer] Remove extra semicolons 2019-02-26 17:46:13 +00:00
FuzzerValueBitMap.h [libFuzzer][MSVC] Enable building libFuzzer with MSVC 2019-01-22 18:59:25 +00:00
README.txt [libFuzzer] better README.txt 2017-08-22 01:15:40 +00:00
build.sh Switch from Bourne shell to simply base shell to build libfuzzer 2018-01-12 23:45:24 +00:00

README.txt

See http://llvm.org/docs/LibFuzzer.html