| 1 |
This directory contains tests to be run with clang's libFuzzer. It will generate data, pass this |
| 2 |
data to the function |
| 3 |
|
| 4 |
LLVMFuzzerTestOneInput(const char *Data, size_t Size) |
| 5 |
|
| 6 |
of the test and track the code execution. Should the test crash, libFuzzer will provide you with the |
| 7 |
data which triggered the crash. You can then use this to debug and fix the called code. |
| 8 |
|
| 9 |
! Please note: The purpose of fuzz testing is to find unexpected code paths. Running fuzz tests may! |
| 10 |
! result in unforeseen behavior, including loss of data. Consider running the tests in an isolated ! |
| 11 |
! environment, e.g. on a virtual machine. You have been warned. ! |
| 12 |
|
| 13 |
To run a test with libFuzzer: |
| 14 |
|
| 15 |
1. Install clang 5.0 or later, e.g. from the repositories of the Linux distribution you are using. |
| 16 |
Depending on the version of clang and the source you are installing from, you might have to |
| 17 |
install libFuzzer for this version of clang explicitly. |
| 18 |
2. Make sure clang and clang++ from this version of clang are found in PATH. |
| 19 |
3. Configure Qt with |
| 20 |
-platform linux-clang -sanitize fuzzer-no-link |
| 21 |
or, if you are using clang 5 |
| 22 |
-platform linux-clang -coverage trace-pc-guard |
| 23 |
to add the needed code coverage instrumentation. Since speed of execution is crucial for fuzz |
| 24 |
testing, it's recommendable to also use the switches |
| 25 |
-release -static |
| 26 |
It might also make sense to add sanitizers by passing |
| 27 |
-sanitize <...> |
| 28 |
4. Build Qt. |
| 29 |
5. Build one of the tests using this Qt build. |
| 30 |
6. Execute the resulting executable. |
| 31 |
Depending on the expected input format of the tested function, you will get results faster if |
| 32 |
you: |
| 33 |
* provide a set of interesting input data by passing the path of a directory which contains |
| 34 |
these data, each in one file. You can find such data sets in the subdirectory |
| 35 |
"fuzzing/testcases" of the qtqa repository. |
| 36 |
* pass a so-called dictionary listing keywords of the input format using |
| 37 |
-dict=<dictionary file> |
| 38 |
A couple of such dictionaries are provided by AFL (http://lcamtuf.coredump.cx/afl/) |
| 39 |
* tell libFuzzer to generate only ASCII data using |
| 40 |
-only_ascii=1 |
| 41 |
|
| 42 |
For further info about libFuzzer, see https://llvm.org/docs/LibFuzzer.html |
| 43 |
|
| 44 |
Some of these tests are continuously being run on oss-fuzz which is documented at |
| 45 |
https://google.github.io/oss-fuzz/ |
| 46 |
|
| 47 |
You can find: |
| 48 |
- The build logs for Qt at |
| 49 |
https://oss-fuzz-build-logs.storage.googleapis.com/index.html#qt |
| 50 |
- The code coverage of the running fuzzers at |
| 51 |
https://storage.googleapis.com/oss-fuzz-coverage/qt/reports/20201104/linux/report.html |
| 52 |
Update the date in the URL to get more recent data. |
| 53 |
- The found issues which were already published at: |
| 54 |
https://bugs.chromium.org/p/oss-fuzz/issues/list?q=proj%3Dqt |