From 422df7dab4003dcd83479a5bfb1855a3c0ca4911 Mon Sep 17 00:00:00 2001 From: Guido Vranken Date: Tue, 3 Jul 2018 18:51:01 +0200 Subject: [PATCH] GNU multiprecision (libgmp) fuzzer (#1587) * Build OpenSSL+libgmp fuzzer * Fix comment typo --- projects/bignum-fuzzer/Dockerfile | 3 ++- projects/bignum-fuzzer/build.sh | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/projects/bignum-fuzzer/Dockerfile b/projects/bignum-fuzzer/Dockerfile index 6ce2c8d19..bd504a0e1 100644 --- a/projects/bignum-fuzzer/Dockerfile +++ b/projects/bignum-fuzzer/Dockerfile @@ -16,7 +16,7 @@ FROM gcr.io/oss-fuzz-base/base-builder MAINTAINER guidovranken@gmail.com -RUN apt-get update && apt-get install -y software-properties-common python-software-properties wget curl sudo libboost-all-dev +RUN apt-get update && apt-get install -y software-properties-common python-software-properties wget curl sudo mercurial autoconf bison texinfo libboost-all-dev RUN add-apt-repository -y ppa:gophers/archive && apt-get update && apt-get install -y golang-1.9-go RUN ln -s /usr/lib/go-1.9/bin/go /usr/bin/go @@ -25,4 +25,5 @@ RUN curl -s https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly RUN git clone --depth 1 https://github.com/guidovranken/bignum-fuzzer RUN git clone --depth 1 https://github.com/openssl/openssl +RUN hg clone https://gmplib.org/repo/gmp/ libgmp/ COPY build.sh $SRC/ diff --git a/projects/bignum-fuzzer/build.sh b/projects/bignum-fuzzer/build.sh index a0e0a5258..5f2ae008e 100755 --- a/projects/bignum-fuzzer/build.sh +++ b/projects/bignum-fuzzer/build.sh @@ -6,6 +6,12 @@ fi ./config make -j$(nproc) +# Build libgmp +cd $SRC/libgmp +autoreconf -ivf +./configure --enable-maintainer-mode +make -j$(nproc) + # Build OpenSSL module cd $SRC/bignum-fuzzer/modules/openssl OPENSSL_INCLUDE_PATH=$SRC/openssl/include OPENSSL_LIBCRYPTO_A_PATH=$SRC/openssl/libcrypto.a make @@ -22,6 +28,10 @@ make cd $SRC/bignum-fuzzer/modules/cpp_boost make +# Build libgmp module +cd $SRC/bignum-fuzzer/modules/libgmp +LIBGMP_INCLUDE_PATH=$SRC/libgmp LIBGMP_A_PATH=$SRC/libgmp/.libs/libgmp.a make + BASE_CXXFLAGS=$CXXFLAGS # Build OpenSSL/Go fuzzer @@ -53,7 +63,18 @@ LIBFUZZER_LINK="-lFuzzingEngine" make # Copy OpenSSL/C++-Boost fuzzer to the designated location cp $SRC/bignum-fuzzer/fuzzer $OUT/fuzzer_openssl_cpp_boost_num_len_1200_all_operations_num_loops_1 +# Build OpenSSL/libgmp fuzzer +cd $SRC/bignum-fuzzer +make clean +./config-modules.sh openssl libgmp +CXXFLAGS="$BASE_CXXFLAGS -DBNFUZZ_FLAG_NUM_LEN=1200 -DBNFUZZ_FLAG_ALL_OPERATIONS=1 -DBNFUZZ_FLAG_NUM_LOOPS=1" +LIBFUZZER_LINK="-lFuzzingEngine" make + +# Copy OpenSSL/libgmp fuzzer to the designated location +cp $SRC/bignum-fuzzer/fuzzer $OUT/fuzzer_openssl_libgmp_num_len_1200_all_operations_num_loops_1 + # Copy seed corpora to the designated location cp $SRC/bignum-fuzzer/corpora/fuzzer_openssl_go_no_negative_num_len_1200_all_operations_seed_corpus.zip $OUT cp $SRC/bignum-fuzzer/corpora/fuzzer_openssl_rust_num_len_1200_all_operations_num_loops_1_seed_corpus.zip $OUT cp $SRC/bignum-fuzzer/corpora/fuzzer_openssl_cpp_boost_num_len_1200_all_operations_num_loops_1_seed_corpus.zip $OUT +cp $SRC/bignum-fuzzer/corpora/fuzzer_openssl_libgmp_num_len_1200_all_operations_num_loops_1_seed_corpus.zip $OUT