Kostya Serebryany
9838b2be87
[libFuzzer] adding a parser for AFL-style dictionaries + tests.
...
llvm-svn: 246800
2015-09-03 20:23:46 +00:00
Kostya Serebryany
6ea1b69fcf
[libFuzzer] deprecate the -tokens flag. This was a bad idea because the corpus with this flag contains encrypted inputs, not the real inputs, which complicates interoperation with other fuzzers. Instead we'll need to implement AFL dictionary support
...
llvm-svn: 246734
2015-09-02 23:27:39 +00:00
Kostya Serebryany
a9346c2e65
[libFuzzer] honour -only_ascii=1 when reading the initial corpus. Also, remove ugly #ifdef
...
llvm-svn: 246689
2015-09-02 19:08:08 +00:00
Kostya Serebryany
06c199ac9d
[libFuzzer] fix minor inefficiency, PR24584
...
llvm-svn: 246087
2015-08-26 21:55:19 +00:00
Lenny Maiorani
1230a54970
Fix missing space in libfuzzer's help text.
...
llvm-svn: 244800
2015-08-12 20:00:10 +00:00
Kostya Serebryany
12c7837381
[libFuzzer] add two flags, -tbm_depth and -tbm_width to control how the trace-based-mutations are applied
...
llvm-svn: 244712
2015-08-12 01:55:37 +00:00
Kostya Serebryany
1688098cb5
[libFuzzer] add colons to the stats output to avoid confusion
...
llvm-svn: 244708
2015-08-12 01:04:27 +00:00
Kostya Serebryany
ac25eeba76
[libFuzzer] use raw C IO to reduce the risk of a deadlock in a signal handler.
...
llvm-svn: 244707
2015-08-12 00:55:09 +00:00
Nick Lewycky
69ab31a3fa
Fix unused variable 'X' in release builds.
...
llvm-svn: 244571
2015-08-11 05:57:10 +00:00
Kostya Serebryany
bc7c0ad24d
[libFuzzer] add -only_ascii flag
...
llvm-svn: 244559
2015-08-11 01:44:42 +00:00
Yaron Keren
347663b214
Add missing include guard to FuzzerInternal.h, NFC.
...
llvm-svn: 244457
2015-08-10 16:37:40 +00:00
Kostya Serebryany
242ca930e8
[libFuzzer] move the mutators to public interface so that custom mutators may reuse these functions directly
...
llvm-svn: 244250
2015-08-06 19:19:55 +00:00
Kostya Serebryany
bf29ff2fa5
[libFuzzer] add one more mutation strategy: byte shuffling
...
llvm-svn: 244188
2015-08-06 01:29:13 +00:00
Kostya Serebryany
d46369d8b3
[libFuzzer] avoid build warnings in non-assert build (useful warning in this case)
...
llvm-svn: 244177
2015-08-05 23:44:42 +00:00
Kostya Serebryany
4cc10d432a
[libFuzzer] in dfsan mode, set labels every time we start recording traces as opposed to doing it at process startup. This ensures that the labels are fresh.
...
llvm-svn: 244165
2015-08-05 23:02:57 +00:00
Kostya Serebryany
70926aed6b
[libFuzzer] add option -report_slow_units=Nsec to control when slow units are printed
...
llvm-svn: 244152
2015-08-05 21:43:48 +00:00
Kostya Serebryany
1ce0035bf0
[libFuzzer] add a missing test file
...
llvm-svn: 244151
2015-08-05 21:32:13 +00:00
Kostya Serebryany
7f4227d59a
[libFuzzer] use data-flow feedback from strcmp
...
llvm-svn: 244084
2015-08-05 18:23:01 +00:00
Kostya Serebryany
86a5fba71d
[libFuzzer] more refactoring of the Mutator and adding tests to it
...
llvm-svn: 243818
2015-08-01 02:23:06 +00:00
Kostya Serebryany
8ce7424e9c
[libFuzzer] start refactoring the Mutator and adding tests to it
...
llvm-svn: 243817
2015-08-01 01:42:51 +00:00
Kostya Serebryany
1165efdbf9
[libFuzzer] limit the size of the inputs printed to stderr
...
llvm-svn: 243795
2015-07-31 22:07:17 +00:00
Kostya Serebryany
fe7e41e8f5
[libFuzzer] make sure that 2-byte arguments of switch() are handled properly
...
llvm-svn: 243781
2015-07-31 20:58:55 +00:00
Kostya Serebryany
73932e5fe3
[libFuzzer] record traces from the switch statements only when told to do so
...
llvm-svn: 243768
2015-07-31 18:09:08 +00:00
Kostya Serebryany
cd6a4665e0
[libFuzzer] support switch interception in dfsan mode
...
llvm-svn: 243760
2015-07-31 17:05:05 +00:00
Kostya Serebryany
fb7d8d9d06
[libFuzzer] trace switch statements and apply mutations based on the expected case values
...
llvm-svn: 243726
2015-07-31 01:33:06 +00:00
Kostya Serebryany
c9dc96bfc6
[libFuzzer] fix the strncmp interceptor -- it should respect short strings.
...
llvm-svn: 243691
2015-07-30 21:22:22 +00:00
Kostya Serebryany
b74ba421fc
[libFuzzer] implement strncmp hook for data-flow-guided fuzzing (w/ and w/o dfsan), add a test
...
llvm-svn: 243611
2015-07-30 02:33:45 +00:00
Kostya Serebryany
0e776a2250
[libFuzzer] implement memcmp hook for data-flow-guided fuzzing (w/o dfsan), extend the memcmp fuzzer test
...
llvm-svn: 243603
2015-07-30 01:34:58 +00:00
Kostya Serebryany
ae7df1ca4d
[libFuzzer] ensure that the dfsan tracing hooks actually run (using -verbosity=3 in tests)
...
llvm-svn: 243365
2015-07-28 01:25:00 +00:00
Kostya Serebryany
35959592a3
[libFuzzer] when using cmp traces, first check that the CMP is evaluated to one value much more frequently than to the other value (heuristic)
...
llvm-svn: 243363
2015-07-28 00:59:53 +00:00
Kostya Serebryany
404c69f2c8
[libFuzzer] allow users to supply their own implementation of rand
...
llvm-svn: 243078
2015-07-24 01:06:40 +00:00
Kostya Serebryany
2b7d2e91cc
[libFuzzer] dump long running units to disk
...
llvm-svn: 243031
2015-07-23 18:37:22 +00:00
Alexey Samsonov
4800c2de28
[Fuzzer] Rely on $PATH expansion instead of hardcoding paths in tests. NFC.
...
llvm-svn: 242851
2015-07-21 22:51:55 +00:00
Alexey Samsonov
dc324e1644
[Fuzzer] Clearly separate regular and DFSan tests. NFC.
...
llvm-svn: 242850
2015-07-21 22:51:49 +00:00
Kostya Serebryany
86e4a3e0a3
[libFuzzer] require the files and directories passed to the fuzzer to exist
...
llvm-svn: 242596
2015-07-18 00:03:37 +00:00
Kostya Serebryany
2ea204e645
[lib/Fuzzer] make assertions more informative and update comments for the user-supplied mutator
...
llvm-svn: 238658
2015-05-30 17:33:13 +00:00
Kostya Serebryany
3fe7682fb0
[lib/Fuzzer] relax an assertion
...
llvm-svn: 238608
2015-05-29 20:31:17 +00:00
Kostya Serebryany
316b571007
[lib/Fuzzer] make the fuzzing timeout 1200 seconds by default (was: infinity)
...
llvm-svn: 238251
2015-05-26 20:57:47 +00:00
Kostya Serebryany
c5f905cceb
[lib/Fuzzer] fix docs
...
llvm-svn: 238236
2015-05-26 19:32:52 +00:00
Kostya Serebryany
c8228dd9fb
[lib/Fuzzer] fix build with assertions
...
llvm-svn: 238235
2015-05-26 19:29:33 +00:00
Kostya Serebryany
e0d60ba876
[lib/Fuzzer] doxygen-ify the comments for the user interface
...
llvm-svn: 238086
2015-05-23 02:12:05 +00:00
Kostya Serebryany
7c180eafc1
[lib/Fuzzer] fully get rid of std::cerr in libFuzzer
...
llvm-svn: 238081
2015-05-23 01:22:35 +00:00
Kostya Serebryany
20e9bcbfc8
[lib/Fuzzer] start getting rid of std::cerr. Sadly, these parts of C++ library used in libFuzzer badly interract with the same code used in the target function and also with dfsan. It's easier to just not use std::cerr than to defeat these issues.
...
llvm-svn: 238078
2015-05-23 01:07:46 +00:00
Kostya Serebryany
f3c7cb464e
[lib/Fuzzer] remove -use_coverage_pairs=1, an experimental feature that is unlikely to ever scale
...
llvm-svn: 238063
2015-05-22 22:47:03 +00:00
Kostya Serebryany
f342459aa4
[lib/Fuzzer] extend the fuzzer interface to allow user-supplied mutators
...
llvm-svn: 238059
2015-05-22 22:35:31 +00:00
Kostya Serebryany
71e0feb1ac
[lib/Fuzzer] ignore flags that start with --; use git pull --rebase instead of just git pull
...
llvm-svn: 237950
2015-05-21 20:39:13 +00:00
Kostya Serebryany
490bbd6fa4
[lib/Fuzzer] change the meaning of -timeout flag: now timeout is applied to every unit of work separately
...
llvm-svn: 237735
2015-05-19 22:12:57 +00:00
Kostya Serebryany
cbb2334b7a
[lib/Fuzzer] more efficient reload logic; also don't spam git too much
...
llvm-svn: 237649
2015-05-19 01:06:07 +00:00
Kostya Serebryany
2da7b84852
[lib/Fuzzer] when -sync_command=<CMD> is given, periodically execute 'CMD CORPUS' to synchronize with other processes
...
llvm-svn: 237617
2015-05-18 21:34:20 +00:00
Logan Chien
a8f01bc8e1
Code cleanup: Reindent Fuzzer::MutateAndTestOne.
...
llvm-svn: 237533
2015-05-17 02:44:31 +00:00
Kostya Serebryany
96eab65d81
[lib/Fuzzer] Add SHA1 implementation from public domain.
...
Summary:
This adds a SHA1 implementation taken from public domain code.
The change is trivial, but as it involves third-party code I'd like
a second pair of eyes before commit.
LibFuzzer can not use SHA1 from openssl because openssl may not be available
and because we may be fuzzing openssl itself.
Using sha1sum via a pipe is too slow.
Test Plan: n/a
Reviewers: chandlerc
Reviewed By: chandlerc
Subscribers: majnemer, llvm-commits
Differential Revision: http://reviews.llvm.org/D9733
llvm-svn: 237400
2015-05-14 22:41:49 +00:00
Kostya Serebryany
1ce4ebf7d6
[lib/Fuzzer] enable -use_counters=1 by default
...
llvm-svn: 237272
2015-05-13 18:31:46 +00:00
Kostya Serebryany
80ec5a11b5
[lib/Fuzzer] A simple script to synchronise a fuzz test corpus with an external git repository.
...
llvm-svn: 237208
2015-05-12 23:19:12 +00:00
Kostya Serebryany
f47198aa36
[lib/Fuzzer] use sha1sum for the file hash
...
llvm-svn: 237198
2015-05-12 22:03:34 +00:00
Kostya Serebryany
9690fcf12e
[lib/Fuzzer] guess the right number of workers if -jobs=N is given but -workers=M is not. Update the docs.
...
llvm-svn: 237163
2015-05-12 18:51:57 +00:00
Kostya Serebryany
d8c54724a8
[lib/Fuzzer] remove the -dfsan=1 flag, just use -use_traces=1 (w/ or w/o dfsan)
...
llvm-svn: 237083
2015-05-12 01:58:34 +00:00
Kostya Serebryany
cd7629caec
[lib/Fuzzer] detach the pulse thread instad of joining it
...
llvm-svn: 237082
2015-05-12 01:43:20 +00:00
Kostya Serebryany
8817e86efd
[lib/Fuzzer] don't record traces when trace collection is off
...
llvm-svn: 237067
2015-05-11 23:25:28 +00:00
Kostya Serebryany
83fd486ff4
[lib/Fuzzer] when running multiple fuzzing processes, print something every 10 minutes to avoid buildbot timeouts
...
llvm-svn: 237054
2015-05-11 21:31:51 +00:00
Kostya Serebryany
225262562f
[lib/Fuzzer] rename FuzzerDFSan.cpp to FuzzerTraceState.cpp; update comments. NFC expected
...
llvm-svn: 237050
2015-05-11 21:16:27 +00:00
Kostya Serebryany
5a99ecbbb3
[lib/Fuzzer] add a trace-based mutatation logic. Same idea as with DFSan-based mutator, but instead of relying on taint tracking, try to find the data directly in the input. More (logic and comments) to go.
...
llvm-svn: 237043
2015-05-11 20:51:19 +00:00
Kostya Serebryany
f3f3ed323a
[lib/Fuzzer] build tests that work well with dfsan also w/o dfsan
...
llvm-svn: 236909
2015-05-08 21:45:19 +00:00
Kostya Serebryany
1ac8055bc7
[lib/Fuzzer] use -fsanitize-coverage=trace-cmp when building LLVM with LLVM_USE_SANITIZE_COVERAGE; in lib/Fuzzer try to reload the corpus to pick up new units from other processes
...
llvm-svn: 236906
2015-05-08 21:30:55 +00:00
Alexey Samsonov
21a3381a38
Update CMake flags, LibFuzzer comments and docs for new -fsanitize-coverage= flags.
...
llvm-svn: 236797
2015-05-07 23:33:24 +00:00
Kostya Serebryany
beb24c38e7
[lib/Fuzzer] change the way we use taint information for fuzzing. Now, we run a single unit and collect suggested mutations based on tracing+taint data, then apply the suggested mutations one by one. The previous scheme was slower and more complex.
...
llvm-svn: 236772
2015-05-07 21:02:11 +00:00
Kostya Serebryany
7d470cfb0c
[lib/Fuzzer] minor refactoring/simplification, NFC
...
llvm-svn: 236757
2015-05-07 18:32:29 +00:00
Kostya Serebryany
a407ddef27
[lib/Fuzzer] add dfsan_weak_hook_memcmp, enable the test that uses it, simplify the test runner
...
llvm-svn: 236683
2015-05-07 00:11:33 +00:00
Kostya Serebryany
3befe94acb
[lib/Fuzzer] remove dfsan_fuzzer_abi.list -- its contents are now moved to dfsan proper
...
llvm-svn: 236659
2015-05-06 22:47:24 +00:00
Kostya Serebryany
754f55d6f5
[lib/Fuzzer] add a fuzzer test for memcmp (does not work yet)
...
llvm-svn: 236656
2015-05-06 22:36:00 +00:00
Kostya Serebryany
566bc5aa8a
[lib/Fuzzer] rename TestOneInput to LLVMFuzzerTestOneInput to make it more unique
...
llvm-svn: 236652
2015-05-06 22:19:00 +00:00
Kostya Serebryany
ca6a2a2f1c
[lib/Fuzzer] on crash print the contents of the crashy input as base64
...
llvm-svn: 236548
2015-05-05 21:59:51 +00:00
Kostya Serebryany
177582c90f
[lib/Fuzzer] use handle_abort=1 by default so that when assert() fires we save the test case
...
llvm-svn: 236476
2015-05-05 01:42:55 +00:00
Aaron Ballman
f77031f99d
Removing a spurious space; NFC.
...
llvm-svn: 234168
2015-04-06 16:09:13 +00:00
Kostya Serebryany
043ab1c8a7
[fuzzer] document the -tokens flag. Also change the diagnostic output
...
llvm-svn: 233842
2015-04-01 21:33:20 +00:00
Kostya Serebryany
52a788e503
[fuzzer] Add support for token-based fuzzing (e.g. for C++). Allow string flags.
...
llvm-svn: 233745
2015-03-31 20:13:20 +00:00
Kostya Serebryany
35ce8630f3
Move lib/Fuzzer docs from a README.txt to a proper .rst file.
...
Summary:
Move lib/Fuzzer docs from a README.txt to a proper .rst file.
This change does not add any content, just formatting.
Test Plan: n/a
Reviewers: samsonov
Reviewed By: samsonov
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D8710
llvm-svn: 233638
2015-03-30 23:05:30 +00:00
Kostya Serebryany
16901a901d
[fuzzer] when a single unit takes over 1 second to run and it is the slowest one so far, print it.
...
llvm-svn: 233637
2015-03-30 23:04:35 +00:00
Kostya Serebryany
03db8b9225
[fuzzer] print various stats in a unified way
...
llvm-svn: 233624
2015-03-30 22:44:03 +00:00
Kostya Serebryany
16d03bd051
DFSan-based fuzzer (proof of concept).
...
Summary:
This adds a simple DFSan-based (i.e. taint-guided) fuzzer mutator,
see the comments for details.
Test Plan: a test added
Reviewers: samsonov, pcc
Reviewed By: samsonov, pcc
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D8669
llvm-svn: 233613
2015-03-30 22:09:51 +00:00
Kostya Serebryany
be5e0ed919
[sanitizer/coverage] Add AFL-style coverage counters (search heuristic for fuzzing).
...
Introduce -mllvm -sanitizer-coverage-8bit-counters=1
which adds imprecise thread-unfriendly 8-bit coverage counters.
The run-time library maps these 8-bit counters to 8-bit bitsets in the same way
AFL (http://lcamtuf.coredump.cx/afl/technical_details.txt ) does:
counter values are divided into 8 ranges and based on the counter
value one of the bits in the bitset is set.
The AFL ranges are used here: 1, 2, 3, 4-7, 8-15, 16-31, 32-127, 128+.
These counters provide a search heuristic for single-threaded
coverage-guided fuzzers, we do not expect them to be useful for other purposes.
Depending on the value of -fsanitize-coverage=[123] flag,
these counters will be added to the function entry blocks (=1),
every basic block (=2), or every edge (=3).
Use these counters as an optional search heuristic in the Fuzzer library.
Add a test where this heuristic is critical.
llvm-svn: 231166
2015-03-03 23:27:02 +00:00
Kostya Serebryany
2e3622bddd
[fuzzer] one more experimental search mode: -use_coverage_pairs=1
...
llvm-svn: 229957
2015-02-20 03:02:37 +00:00
Kostya Serebryany
016852c396
[fuzzer] split main() into FuzzerDriver() that takes a callback as a parameter and a tiny main() in a separate file
...
llvm-svn: 229882
2015-02-19 18:45:37 +00:00
Kostya Serebryany
2117269dd1
[fuzzer] properly annotate fallthrough, add one more entry to FAQ
...
llvm-svn: 229880
2015-02-19 18:21:12 +00:00
Kostya Serebryany
db4d645714
[fuzzer] move default sanitizer options to a separate file
...
llvm-svn: 228429
2015-02-06 19:52:07 +00:00
Kostya Serebryany
92e0476c67
[fuzzer] add flag prefer_small_during_initial_shuffle, be a bit more verbose
...
llvm-svn: 228235
2015-02-04 23:42:42 +00:00
Kostya Serebryany
33f866922a
[fuzzer] add -runs=N to limit the number of runs per session. Also, make sure we do some mutations w/o cross over.
...
llvm-svn: 228214
2015-02-04 22:20:09 +00:00
Kostya Serebryany
5b266a8a23
[fuzzer] make multi-process execution more verbose; fix mutation to actually respect mutation depth and to never produce empty units
...
llvm-svn: 228170
2015-02-04 19:10:20 +00:00
Kostya Serebryany
fe43aa8d19
[fuzzer]: fix exit code, add more diagnostics
...
llvm-svn: 228103
2015-02-04 01:22:57 +00:00
Kostya Serebryany
cf9fdd5876
[fuzzer] Add proper dependensices to the fuzzer tests
...
Summary: Make sure that FileCheck is built when running check-fuzzer
Test Plan:
run on bot:
lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fuzzer
Reviewers: samsonov
Reviewed By: samsonov
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D7387
llvm-svn: 228045
2015-02-03 21:57:32 +00:00
Kostya Serebryany
4b96ce96c6
[fuzzer] update the include line to use the new header name
...
llvm-svn: 228018
2015-02-03 19:42:05 +00:00
Kostya Serebryany
e8cee11570
[fuzzer] add flags to run fuzzer in multiple parallel processes
...
llvm-svn: 227664
2015-01-31 01:14:40 +00:00
Kostya Serebryany
71672552db
[fuzzer] Add a gtest-style test
...
Summary: Add one gtest-style test.
Test Plan: run on bot
Reviewers: samsonov
Reviewed By: samsonov
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D7287
llvm-svn: 227639
2015-01-30 23:26:57 +00:00
Kostya Serebryany
2c1b33b897
[fuzzer] add -use_full_coverage_set=1 which solves FullCoverageSetTest. This does not scale very well yet, but might be a good start.
...
llvm-svn: 227507
2015-01-29 23:01:07 +00:00
Kostya Serebryany
0ff86c79b4
[fuzzer] fix warning in a test
...
llvm-svn: 227478
2015-01-29 18:13:36 +00:00
Kostya Serebryany
6d768fcc18
[fuzzer] minor cleanup based on reviews: remove redundant includes, fix a copy-pasto in tests
...
llvm-svn: 227468
2015-01-29 17:16:23 +00:00
Kostya Serebryany
a1849af4a9
[fuzzer] add FAQ section to the README.txt
...
llvm-svn: 227466
2015-01-29 17:11:30 +00:00
Aaron Ballman
ef11698cac
Reverting r227452, which adds back the fuzzer library. Now excluding the fuzzer library based on LLVM_USE_SANITIZE_COVERAGE being set or unset.
...
llvm-svn: 227464
2015-01-29 16:58:29 +00:00
Aaron Ballman
7b54ed221a
Temporarily reverting the fuzzer library as it causes too many build issues for MSVC users. This reverts: 227445, 227395, 227389, 227357, 227254, 227252
...
llvm-svn: 227452
2015-01-29 15:49:22 +00:00
Aaron Ballman
d39df1e24d
Adding missing #includes to try to get this to compile on Windows with Visual Studio.
...
llvm-svn: 227445
2015-01-29 15:19:13 +00:00
Kostya Serebryany
265cf04f9c
[fuzzer] add option -save_minimized_corpus
...
llvm-svn: 227395
2015-01-28 23:48:39 +00:00
Kostya Serebryany
a8fbcf0c1f
Add lit-style tests for the Fuzzer library
...
Summary: Add test targets and the lit-style runner.
Test Plan: Run the tests on bot.
Reviewers: samsonov
Reviewed By: samsonov
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D7217
llvm-svn: 227389
2015-01-28 22:49:25 +00:00
Kostya Serebryany
e6972a029f
[fuzzer] instructions for building/running clang-format-fuzzer
...
llvm-svn: 227357
2015-01-28 19:51:58 +00:00
Kostya Serebryany
bfa3f9d82f
[fuzzer] properly enable asan's coverage feedback
...
llvm-svn: 227254
2015-01-27 22:19:55 +00:00
Kostya Serebryany
d53b43fe11
Add a Fuzzer library
...
Summary:
A simple genetic in-process coverage-guided fuzz testing library.
I've used this fuzzer to test clang-format
(it found 12+ bugs, thanks djasper@ for the fixes!)
and it may also help us test other parts of LLVM.
So why not keep it in the LLVM repository?
I plan to add the cmake build rules later (in a separate patch, if that's ok)
and also add a clang-format-fuzzer target.
See README.txt for details.
Test Plan: Tests will follow separately.
Reviewers: djasper, chandlerc, rnk
Reviewed By: rnk
Subscribers: majnemer, ygribov, dblaikie, llvm-commits
Differential Revision: http://reviews.llvm.org/D7184
llvm-svn: 227252
2015-01-27 22:08:41 +00:00