Skip to content

Commit a789f19

Browse files
Hackhackhack...
1 parent 0145886 commit a789f19

File tree

3 files changed

+121
-0
lines changed

3 files changed

+121
-0
lines changed

infra/build_fuzzers.Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ WORKDIR ${OSS_FUZZ_ROOT}/infra
2727

2828
# Update infra source code.
2929
ADD . ${OSS_FUZZ_ROOT}/infra
30+
COPY ./openssl/* ${OSS_FUZZ_ROOT}/projects/openssl/
3031

3132
RUN python3 -m pip install -r ${OSS_FUZZ_ROOT}/infra/cifuzz/requirements.txt

infra/openssl/Dockerfile

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2016 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
################################################################################
16+
17+
FROM gcr.io/oss-fuzz-base/base-builder
18+
RUN apt-get update && apt-get install -y make
19+
RUN git clone --depth 1 https://github.com/openssl/openssl.git
20+
RUN cd $SRC/openssl/ && git submodule update --init fuzz/corpora
21+
RUN git clone --depth 1 --branch openssl-3.0 https://github.com/openssl/openssl.git openssl30
22+
RUN git clone --depth 1 --branch openssl-3.1 https://github.com/openssl/openssl.git openssl31
23+
RUN git clone --depth 1 --branch openssl-3.2 https://github.com/openssl/openssl.git openssl32
24+
RUN cd $SRC/openssl32/ && git submodule update --init fuzz/corpora
25+
WORKDIR openssl
26+
COPY build.sh *.options $SRC/
27+
ENV AFL_SKIP_OSSFUZZ=1
28+
ENV AFL_LLVM_MODE_WORKAROUND=0

infra/openssl/build.sh

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/bash -eu
2+
# Copyright 2016 Google Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
################################################################################
17+
18+
export FUZZ_INTROSPECTOR_CONFIG=$SRC/openssl/fuzz/fuzz_introspector_exclusion.config
19+
20+
CONFIGURE_FLAGS="--debug enable-fuzz-libfuzzer -DPEDANTIC -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION no-shared enable-tls1_3 enable-rc5 enable-md2 enable-ssl3 enable-ssl3-method enable-nextprotoneg enable-weak-ssl-ciphers --with-fuzzer-lib=/usr/lib/libFuzzingEngine $CFLAGS -fno-sanitize=alignment"
21+
if [[ $CFLAGS = *sanitize=memory* ]]
22+
then
23+
CONFIGURE_FLAGS="$CONFIGURE_FLAGS no-asm"
24+
fi
25+
if [[ $CFLAGS != *-m32* ]]
26+
then
27+
CONFIGURE_FLAGS="$CONFIGURE_FLAGS enable-ec_nistp_64_gcc_128"
28+
fi
29+
if [[ $CFLAGS = *-m32* ]]
30+
then
31+
# Prevent error:
32+
#
33+
# error while loading shared libraries:
34+
# libatomic.so.1: cannot open shared object file:
35+
# No such file or directory
36+
CONFIGURE_FLAGS="$CONFIGURE_FLAGS no-threads"
37+
fi
38+
39+
function build_fuzzers() {
40+
SUFFIX=$1
41+
if [[ $CFLAGS = *-m32* ]]
42+
then
43+
setarch i386 ./config $CONFIGURE_FLAGS
44+
else
45+
./config $CONFIGURE_FLAGS
46+
fi
47+
48+
make -j$(nproc) LDCMD="$CXX $CXXFLAGS"
49+
50+
fuzzers=$(find fuzz -executable -type f '!' -name \*.py '!' -name \*-test '!' -name \*.pl '!' -name \*.sh)
51+
for f in $fuzzers; do
52+
fuzzer=$(basename $f)
53+
cp $f $OUT/${fuzzer}${SUFFIX}
54+
zip -j $OUT/${fuzzer}${SUFFIX}_seed_corpus.zip fuzz/corpora/${fuzzer}/*
55+
done
56+
57+
options=$(find $SRC/ -maxdepth 1 -name '*.options')
58+
for o in $options; do
59+
o_base=$(basename $o)
60+
fuzzer=${o_base%".options"}
61+
cp $o $OUT/${fuzzer}${SUFFIX}.options
62+
done
63+
cp fuzz/oids.txt $OUT/asn1${SUFFIX}.dict
64+
cp fuzz/oids.txt $OUT/x509${SUFFIX}.dict
65+
if [ "$SANITIZER" == coverage ]; then
66+
DESTDIR=$OUT/src/openssl${SUFFIX#_}
67+
SOURCES="include crypto ssl providers engines fuzz"
68+
mkdir -p $DESTDIR
69+
if [ -f e_os.h ]; then
70+
cp e_os.h $DESTDIR/
71+
fi
72+
find $SOURCES -type f -a \( -name '*.[ch]' -o -name '*.inc' \) -exec cp --parents '{}' $DESTDIR/ \;
73+
fi
74+
df
75+
rm -rf * .git*
76+
df
77+
}
78+
79+
cd $SRC/openssl/
80+
build_fuzzers ""
81+
82+
# In introspector only build the master branch
83+
if [[ "$SANITIZER" == introspector ]]; then
84+
exit 0
85+
fi
86+
87+
cd $SRC/openssl30/
88+
build_fuzzers "_30"
89+
cd $SRC/openssl31/
90+
build_fuzzers "_31"
91+
cd $SRC/openssl32/
92+
build_fuzzers "_32"

0 commit comments

Comments
 (0)