From 6eab2634bfbca1227b2a0395e3a170f326d300a8 Mon Sep 17 00:00:00 2001 From: Guido Vranken Date: Fri, 5 Jul 2019 19:12:40 +0200 Subject: [PATCH] Cryptofuzz i386 (#2569) * [cryptofuzz] Enable i386 builds * [cryptofuzz] Enable i386 builds (update project.yaml) --- projects/cryptofuzz/Dockerfile | 1 + projects/cryptofuzz/build.sh | 62 ++++++++++++++++++++++++++------ projects/cryptofuzz/project.yaml | 3 ++ 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/projects/cryptofuzz/Dockerfile b/projects/cryptofuzz/Dockerfile index 4c7307b88..782b65b93 100644 --- a/projects/cryptofuzz/Dockerfile +++ b/projects/cryptofuzz/Dockerfile @@ -37,5 +37,6 @@ RUN wget https://gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.36.tar.bz2 RUN git clone --depth 1 -b oss-fuzz https://github.com/project-everest/hacl-star evercrypt RUN wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_0-stable.zip RUN wget https://github.com/openssl/openssl/archive/OpenSSL_1_0_2-stable.zip +RUN apt-get remove -y libunwind8 COPY build.sh $SRC/ diff --git a/projects/cryptofuzz/build.sh b/projects/cryptofuzz/build.sh index 23cb6c969..3af8c804f 100755 --- a/projects/cryptofuzz/build.sh +++ b/projects/cryptofuzz/build.sh @@ -59,7 +59,12 @@ then cd $SRC/ tar jxvf libgpg-error-1.36.tar.bz2 cd libgpg-error-1.36/ - ./configure --enable-static + if [[ $CFLAGS != *-m32* ]] + then + ./configure --enable-static + else + ./configure --enable-static --host=i386 + fi make -j$(nproc) >/dev/null 2>&1 make install export LINK_FLAGS="$LINK_FLAGS $SRC/libgpg-error-1.36/src/.libs/libgpg-error.a" @@ -67,7 +72,12 @@ then # Compile libgcrypt (with assembly) cd $SRC/libgcrypt autoreconf -ivf - ./configure --enable-static --disable-doc + if [[ $CFLAGS != *-m32* ]] + then + ./configure --enable-static --disable-doc + else + ./configure --enable-static --disable-doc --host=i386 + fi make -j$(nproc) >/dev/null 2>&1 export CXXFLAGS="$CXXFLAGS -DCRYPTOFUZZ_LIBGCRYPT" @@ -97,7 +107,7 @@ then make -B fi -if [[ $CFLAGS != *sanitize=memory* ]] +if [[ $CFLAGS != *sanitize=memory* && $CFLAGS != *-m32* ]] then # Compile EverCrypt (with assembly) cd $SRC/evercrypt/dist @@ -135,7 +145,7 @@ cd $SRC/cryptofuzz/modules/monero make -B ############################################################################## -if [[ $CFLAGS != *sanitize=memory* ]] +if [[ $CFLAGS != *sanitize=memory* && $CFLAGS != *-m32* ]] then # Compile LibreSSL (with assembly) cd $SRC/libressl @@ -168,7 +178,12 @@ if [[ $CFLAGS != *sanitize=memory* ]] then # Compile Openssl (with assembly) cd $SRC/openssl - ./config --debug enable-md2 enable-rc5 + if [[ $CFLAGS != *-m32* ]] + then + ./config --debug enable-md2 enable-rc5 + else + setarch i386 ./config --debug enable-md2 enable-rc5 + fi make -j$(nproc) >/dev/null 2>&1 # Compile Cryptofuzz OpenSSL (with assembly) module @@ -193,7 +208,12 @@ fi ############################################################################## # Compile Openssl (without assembly) cd $SRC/openssl -./config --debug no-asm enable-md2 enable-rc5 +if [[ $CFLAGS != *-m32* ]] +then + ./config --debug no-asm enable-md2 enable-rc5 +else + setarch i386 ./config --debug no-asm enable-md2 enable-rc5 +fi make clean make -j$(nproc) >/dev/null 2>&1 @@ -216,7 +236,7 @@ cp $SRC/cryptofuzz/cryptofuzz-dict.txt $OUT/cryptofuzz-openssl-noasm.dict cp $SRC/cryptofuzz-corpora/openssl_latest.zip $OUT/cryptofuzz-openssl-noasm_seed_corpus.zip ############################################################################## -if [[ $CFLAGS != *sanitize=memory* ]] +if [[ $CFLAGS != *sanitize=memory* && $CFLAGS != *-m32* ]] then # Compile BoringSSL (with assembly) cd $SRC/boringssl @@ -279,7 +299,12 @@ if [[ $CFLAGS != *sanitize=memory* ]] then # Compile Openssl 1.1.0 (with assembly) cd $SRC/openssl-OpenSSL_1_1_0-stable/ - ./config --debug enable-md2 enable-rc5 $CFLAGS + if [[ $CFLAGS != *-m32* ]] + then + ./config --debug enable-md2 enable-rc5 $CFLAGS + else + setarch i386 ./config --debug enable-md2 enable-rc5 $CFLAGS + fi make depend make -j$(nproc) >/dev/null 2>&1 @@ -306,7 +331,12 @@ fi # Compile Openssl 1.1.0 (without assembly) cd $SRC/openssl-OpenSSL_1_1_0-stable/ make clean || true -./config --debug no-asm enable-md2 enable-rc5 $CFLAGS +if [[ $CFLAGS != *-m32* ]] +then + ./config --debug no-asm enable-md2 enable-rc5 $CFLAGS +else + setarch i386 ./config --debug no-asm enable-md2 enable-rc5 $CFLAGS +fi make depend make -j$(nproc) >/dev/null 2>&1 @@ -335,7 +365,12 @@ if [[ $CFLAGS != *sanitize=memory* ]] then # Compile Openssl 1.0.2 (with assembly) cd $SRC/openssl-OpenSSL_1_0_2-stable/ - ./config --debug enable-md2 enable-rc5 $CFLAGS + if [[ $CFLAGS != *-m32* ]] + then + ./config --debug enable-md2 enable-rc5 $CFLAGS + else + setarch i386 ./config --debug enable-md2 enable-rc5 $CFLAGS + fi make depend make -j$(nproc) >/dev/null 2>&1 @@ -362,7 +397,12 @@ fi # Compile Openssl 1.0.2 (without assembly) cd $SRC/openssl-OpenSSL_1_0_2-stable/ make clean || true -./config --debug no-asm enable-md2 enable-rc5 $CFLAGS +if [[ $CFLAGS != *-m32* ]] +then + ./config --debug no-asm enable-md2 enable-rc5 $CFLAGS +else + setarch i386 ./config --debug no-asm enable-md2 enable-rc5 $CFLAGS +fi make depend make -j$(nproc) >/dev/null 2>&1 diff --git a/projects/cryptofuzz/project.yaml b/projects/cryptofuzz/project.yaml index e22c59ca6..bc74b1b47 100644 --- a/projects/cryptofuzz/project.yaml +++ b/projects/cryptofuzz/project.yaml @@ -19,3 +19,6 @@ sanitizers: - address - undefined - memory +architectures: + - x86_64 + - i386