]> git.ipfire.org Git - thirdparty/openssl.git/blame - fuzz/README.md
Enable TLS1.3 and PEDANTIC in the coverage target
[thirdparty/openssl.git] / fuzz / README.md
CommitLineData
c38bb727
BL
1# I Can Haz Fuzz?
2
f59d0131
KR
3LibFuzzer
4=========
5
fe2582a2 6Or, how to fuzz OpenSSL with [libfuzzer](http://llvm.org/docs/LibFuzzer.html).
c38bb727
BL
7
8Starting from a vanilla+OpenSSH server Ubuntu install.
9
10Use Chrome's handy recent build of clang. Older versions may also work.
11
12 $ sudo apt-get install git
13 $ mkdir git-work
14 $ git clone https://chromium.googlesource.com/chromium/src/tools/clang
15 $ clang/scripts/update.py
16
17You may want to git pull and re-run the update from time to time.
18
19Update your path:
20
21 $ PATH=~/third_party/llvm-build/Release+Asserts/bin/:$PATH
22
23Get and build libFuzzer (there is a git mirror at
24https://github.com/llvm-mirror/llvm/tree/master/lib/Fuzzer if you prefer):
25
26 $ cd
27 $ sudo apt-get install subversion
28 $ mkdir svn-work
29 $ cd svn-work
30 $ svn co http://llvm.org/svn/llvm-project/llvm/trunk/lib/Fuzzer
31 $ cd Fuzzer
32 $ clang++ -c -g -O2 -std=c++11 *.cpp
33 $ ar r libFuzzer.a *.o
34 $ ranlib libFuzzer.a
35
36Configure for fuzzing:
37
f59d0131
KR
38 $ CC=clang ./config enable-fuzz-libfuzzer \
39 --with-fuzzer-include=../../svn-work/Fuzzer \
40 --with-fuzzer-lib=../../svn-work/Fuzzer/libFuzzer \
3a9b9b2d 41 -DPEDANTIC enable-asan enable-ubsan no-shared \
0282aeb6
KR
42 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION \
43 -fsanitize-coverage=edge,indirect-calls,8bit-counters
c38bb727
BL
44 $ sudo apt-get install make
45 $ LDCMD=clang++ make -j
31b15b9b 46 $ fuzz/helper.py $FUZZER
c38bb727 47
31b15b9b 48Where $FUZZER is one of the executables in `fuzz/`.
c38bb727
BL
49
50If you get a crash, you should find a corresponding input file in
31b15b9b 51`fuzz/corpora/$FUZZER-crash/`. You can reproduce the crash with
c38bb727 52
31b15b9b 53 $ fuzz/$FUZZER <crashfile>
f59d0131
KR
54
55AFL
56===
57
58Configure for fuzzing:
59
60 $ sudo apt-get install afl-clang
61 $ CC=afl-clang-fast ./config enable-fuzz-afl no-shared
62 $ make
63
64Run one of the fuzzers:
65
31b15b9b 66 $ afl-fuzz -i fuzz/corpora/$FUZZER -o fuzz/corpora/$FUZZER/out fuzz/$FUZZER
f59d0131 67
31b15b9b 68Where $FUZZER is one of the executables in `fuzz/`.