Kostya Serebryany
12ab215732
[libFuzzer] remove stale code; NFC
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307980 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-14 00:16:23 +00:00
Kostya Serebryany
06e0ac200b
[libFuzzer] simplify the handling of memmem/strstr
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307977 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-14 00:06:27 +00:00
Chandler Carruth
e3e43d9d57
Sort the remaining #include lines in include/... and lib/....
...
I did this a long time ago with a janky python script, but now
clang-format has built-in support for this. I fed clang-format every
line with a #include and let it re-sort things according to the precise
LLVM rules for include ordering baked into clang-format these days.
I've reverted a number of files where the results of sorting includes
isn't healthy. Either places where we have legacy code relying on
particular include ordering (where possible, I'll fix these separately)
or where we have particular formatting around #include lines that
I didn't want to disturb in this patch.
This patch is *entirely* mechanical. If you get merge conflicts or
anything, just ignore the changes in this patch and run clang-format
over your #include lines in the files.
Sorry for any noise here, but it is important to keep these things
stable. I was seeing an increasing number of patches with irrelevant
re-ordering of #include lines because clang-format was used. This patch
at least isolates that churn, makes it easy to skip when resolving
conflicts, and gets us to a clean baseline (again).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304787 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-06 11:49:48 +00:00
Kostya Serebryany
9f23ac318f
[libFuzzer] fix a warning from Wunreachable-code-loop-increment reported by Christian Holler. This also fixes a logical bug, which however does not affect the libFuzzer's ability too much (I wasn't able to create a differentiating test)
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303087 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-15 17:39:42 +00:00
Kostya Serebryany
0b84d77114
[libFuzzer] fix a compiler warning
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302747 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-10 23:59:03 +00:00
Kostya Serebryany
f43d588ee8
[libFuzzer] make sure we don't execute libFuzzer's mem* and str* hooks while calling mem*/str* inside libFuzzer itself
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299167 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-31 02:21:28 +00:00
Vitaly Buka
83daa29a86
Revert "[libFuzzer] Use ChooseUnitIdxToMutate to pick item for crossover."
...
Fails LLVMFuzzer.LLVMFuzzer.value-profile-strncmp.test.
This reverts commit r297891.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297912 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-15 23:08:18 +00:00
Vitaly Buka
e925a388a3
[libFuzzer] Use ChooseUnitIdxToMutate to pick item for crossover.
...
Differential Revision: https://reviews.llvm.org/D30683
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297891 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-15 20:59:27 +00:00
Vitaly Buka
c3e4809203
[fuzzer] Don't crash if LLVMFuzzerMutate was called by CustomCrossOver
...
Reviewers: kcc
Subscribers: llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D30682
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297202 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-07 20:37:38 +00:00
Kostya Serebryany
ffcfd0c3bc
[libFuzzer] replace std::random_shuffle with std::shuffle as std::random_shuffle is being deprecated in C++17. Also simplify fuzzer::Random. NFC
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294366 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-07 22:37:34 +00:00
Kostya Serebryany
522017cf0d
[libFuzzer] make code less clever to avoid fallthrough in switch (and in turn avoid compiler warnings). NFC. Suggested by Christian Holler.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294239 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-06 21:21:37 +00:00
Kostya Serebryany
72e0240a06
[libFuzzer] mutate empty input using the regular mutators (instead of a custom dummy one). This way when we mutate an empty input there is a chance we will get a dictionary word
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292843 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-23 22:52:13 +00:00
Kostya Serebryany
1829afedf8
[libFuzzer] ensure that entries in PersistentAutoDictionary are not empty
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292520 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-19 21:14:47 +00:00
Kostya Serebryany
db5325aae3
[libFuzzer] use table of recent compares for memcmp/strcmp (to unify the code between cmp and memcmp handling)
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292287 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 23:09:05 +00:00
Kostya Serebryany
8f45dd30a7
[libFuzzer] don't create large random mutations when given an empty seed
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290634 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-27 22:15:04 +00:00
Daniel Jasper
a21e8a0091
Revert "[libFuzzer] add an experimental flag -experimental_len_control=1 that sets max_len to 1M and tries to increases the actual max sizes of mutations very gradually. Also remove a bit of dead code"
...
This reverts commit r289998.
See comment:
https://reviews.llvm.org/rL289998
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290043 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-17 12:27:49 +00:00
Kostya Serebryany
eb30028464
[libFuzzer] add an experimental flag -experimental_len_control=1 that sets max_len to 1M and tries to increases the actual max sizes of mutations very gradually. Also remove a bit of dead code
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289998 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-16 22:42:05 +00:00
Zachary Turner
1a45ade2ce
Resubmit "[LibFuzzer] Split FuzzerUtil for Posix and Windows."
...
This resubmits r288529, which was resubmitted because it broke a
fuzzer bot. According to kcc@ the test that broke was flakey
and it is unlikely to be a result of this patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288549 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-02 23:02:01 +00:00
Zachary Turner
609477eea7
Revert "[LibFuzzer] Split FuzzerUtil for Posix and Windows."
...
This reverts commit r288529, as it seems to introduce some
problems on the Linux bots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288533 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-02 20:54:56 +00:00
Zachary Turner
fd186677a2
[LibFuzzer] Split FuzzerUtil for Posix and Windows.
...
Pave the way for separating out platform specific
utility functions into separate files.
Patch by Marcos Pividori
Differential Revision: https://reviews.llvm.org/D27234
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288529 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-02 19:38:19 +00:00
Zachary Turner
1a3900e81e
[LibFuzzer] Split up some functions among different headers.
...
In an effort to get libfuzzer working on Windows, we need to make
a distinction between what functions require platform specific
code (e.g. different code on Windows vs Linux) and what code
doesn't. IO functions, for example, tend to be platform
specific.
This patch separates out some of the functions which will need
to have platform specific implementations into different headers,
so that we can then provide different implementations for each
platform.
Aside from that, this patch contains no functional change. It
is purely a re-organization.
Patch by Marcos Pividori
Differential Revision: https://reviews.llvm.org/D27230
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288264 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-30 19:06:14 +00:00
Kostya Serebryany
0895ad474e
[libFuzzer] when mutating based on CMP traces also try adding +/- 1 to the desired bytes. Add another test for use_cmp
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285109 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-25 20:15:15 +00:00
Kostya Serebryany
d2c91bff2f
[libFuzzer] simplify the code for use_cmp, also use the position hint when available, add a test
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285049 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-25 02:04:43 +00:00
Kostya Serebryany
9b71256a5b
[libFuzzer] mutation: insert the size of the input in bytes as one of the ways to mutate a binary integer
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284909 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-22 03:48:53 +00:00
Kostya Serebryany
ce6100541e
[libFuzzer] swap bytes in integers when handling CMP traces
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284301 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-15 04:00:07 +00:00
Kostya Serebryany
3af68729f8
[libFuzzer] add -trace_cmp=1 (guiding mutations based on the observed CMP instructions). This is a reincarnation of the previously deleted -use_traces, but using a different approach for collecting traces. Still a toy, but at least it scales well. Also fix -merge in trace-pc-guard mode
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284273 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-14 20:20:33 +00:00
Kostya Serebryany
e9b850b5c5
[libFuzzer] add 'features' to the corpus elements, allow mutations with Size > MaxSize, fix sha1 in corpus stats; various refactorings
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282129 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-22 01:34:58 +00:00
Kostya Serebryany
e4977b2b7e
[libFuzzer] add stats to the corpus; more refactoring
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282121 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-21 22:42:17 +00:00
Kostya Serebryany
77ab75a9d6
[libFuzzer] more refactoring; NFC
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282047 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-21 02:05:39 +00:00
Kostya Serebryany
2a546868cb
[libFuzzer] refactoring: split the large header into many; NFC
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282044 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-21 01:50:50 +00:00
Kostya Serebryany
47b194388e
[libFuzzer] fix the non-debug build warnings
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279321 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-19 20:57:09 +00:00
Kostya Serebryany
e65e275cf2
[libFuzzer] given 0 and 255 more preference when inserting repeated bytes
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278986 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 21:50:54 +00:00
Kostya Serebryany
9744bb48e4
[libFuzzer] one more mutation: ChangeBinaryInteger; also fix the breakage from r278970
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278982 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 21:30:30 +00:00
Justin Bogner
7d7a23e700
Replace a few more "fall through" comments with LLVM_FALLTHROUGH
...
Follow up to r278902. I had missed "fall through", with a space.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278970 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 20:30:52 +00:00
Kostya Serebryany
79d100891f
[libFuzzer] more mutations
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278950 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 18:10:42 +00:00
Kostya Serebryany
137c3957ed
[libFuzzer] add InsertRepeatedBytes and EraseBytes.
...
New mutation: InsertRepeatedBytes.
Updated mutation: EraseByte => EraseBytes.
This helps https://github.com/google/sanitizers/issues/710
where libFuzzer was not able to find a known bug.
Now it finds it in minutes.
Hopefully, the change is general enough to help other targets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278687 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-15 17:48:28 +00:00
Kostya Serebryany
730992dc3b
[libFuzzer] add hooks for strstr, strcasestr, strcasecmp, strncasecmp
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275648 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 23:27:19 +00:00
Mike Aizatsky
8bbe924637
[libfuzzer] moving is_ascii handler inside mutation dispatcher.
...
Summary: It also fixes a bug, when first random might not be ascii.
Differential Revision: http://reviews.llvm.org/D21573
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273611 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-23 20:44:48 +00:00
Dan Liew
1a1c8bea2d
[LibFuzzer] Declare and use sanitizer functions in `fuzzer::ExternalFunctions`
...
This fixes linking problems on OSX.
Unfortunately it turns out we need to use an instance of the
``fuzzer::ExternalFunctions`` object in several places so this
commit also replaces all instances with a single global instance.
It also turns out initializing a global ``fuzzer::ExternalFunctions``
before main is entered (i.e. letting the object be initialised by the
global initializers) is not safe (on OSX the call to ``Printf()`` in the
CTOR crashes if it is called from a global initializer) so we instead
have a global ``fuzzer::ExternalFunctions*`` and initialize it inside
``FuzzerDriver()``.
Multiple unit tests depend also depend on the
``fuzzer::ExternalFunctions*`` global so a ``main()`` function has been
added that initializes it before running any tests.
Differential Revision: http://reviews.llvm.org/D20943
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272072 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 23:32:50 +00:00
Mike Aizatsky
b1953d8c1b
[libfuzzer] custom crossover interface function.
...
Differential Revision: http://reviews.llvm.org/D21089
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272054 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 20:22:15 +00:00
Mike Aizatsky
664513feca
[libfuzzer] hiding custom mutator handling in MutationDispatcher.
...
Summary: Refactoring, no functional changes.
Differential Revision: http://reviews.llvm.org/D20975
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271740 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 21:34:29 +00:00
Kostya Serebryany
2d7392fe48
[libFuzzer] remove std::vector operations from hot paths, NFC
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260829 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-13 17:56:51 +00:00
Kostya Serebryany
49429cee7f
[libFuzzer] don't require seed in fuzzer::Mutate, instead use the global Fuzzer object for fuzzer::Mutate. This makes custom mutators fast
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260810 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-13 06:24:18 +00:00
Kostya Serebryany
d1eacb8ffc
[libFuzzer] simplify CTOR of MutationDispatcher
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260800 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-13 03:46:26 +00:00
Kostya Serebryany
1d35d47455
[libFuzzer] get rid of MutationDispatcher::Impl (simplify the code; NFC)
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260799 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-13 03:37:24 +00:00
Kostya Serebryany
efb0cc7640
[libFuzzer] get rid of UserSuppliedFuzzer; NFC
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260798 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-13 03:25:16 +00:00
Kostya Serebryany
728ca1266f
[libFuzzer] simplify the code around Random. NFC
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260797 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-13 03:00:53 +00:00
Kostya Serebryany
21a169fad1
[libFuzzer] add more fields to DictionaryEntry to count the number of uses and successes
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258589 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-22 23:55:14 +00:00
Kostya Serebryany
7e85cfa5be
[libFuzzer] don't use std::vector in one more hot path
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258380 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-21 01:52:14 +00:00
Kostya Serebryany
429a7edf9b
[libFuzzer] use std::mt19937 for generating random numbers by default. Fix MyStoll to handle negative values. Use std::any_of instead of std::find_if
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258178 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-19 20:33:57 +00:00