Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fishfuzz test #1934

Closed
wants to merge 15 commits into from
3 changes: 1 addition & 2 deletions fuzzers/aflplusplus/builder.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RUN apt-get update && \
# Download afl++.
RUN git clone -b dev https://github.com/AFLplusplus/AFLplusplus /afl && \
cd /afl && \
git checkout 6f4b5ae0832774389b12c5a8cd3fb95821b438e5 || \
git checkout 4a7e35b29c6711b68d3d579716685c3752ff62a8 || \
true

# Build without Python support as we don't need it.
Expand All @@ -46,5 +46,4 @@ RUN cd /afl && \
unset CFLAGS CXXFLAGS && \
export CC=clang AFL_NO_X86=1 && \
PYTHON_INCLUDE=/ make && \
make install && \
cp utils/aflpp_driver/libAFLDriver.a /
4 changes: 4 additions & 0 deletions fuzzers/aflplusplus/fuzzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def build(*args): # pylint: disable=too-many-branches,too-many-statements
# Generate an extra dictionary.
if 'dict2file' in build_modes or 'native' in build_modes:
os.environ['AFL_LLVM_DICT2FILE'] = build_directory + '/afl++.dict'
os.environ['AFL_LLVM_DICT2FILE_NO_MAIN'] = '1'
# Enable context sentitivity for LLVM mode (non LTO only)
if 'ctx' in build_modes:
os.environ['AFL_LLVM_CTX'] = '1'
Expand Down Expand Up @@ -260,13 +261,16 @@ def fuzz(input_corpus,
if os.path.exists('./afl++.dict'):
flags += ['-x', './afl++.dict']

flags += ['-p', 'explore']

# Move the following to skip for upcoming _double tests:
if os.path.exists(cmplog_target_binary) and no_cmplog is False:
flags += ['-c', cmplog_target_binary]

#os.environ['AFL_IGNORE_TIMEOUTS'] = '1'
os.environ['AFL_IGNORE_UNKNOWN_ENVS'] = '1'
os.environ['AFL_FAST_CAL'] = '1'
os.environ['AFL_NO_WARN_INSTABILITY'] = '1'

if not skip:
os.environ['AFL_DISABLE_TRIM'] = '1'
Expand Down
1 change: 1 addition & 0 deletions fuzzers/aflplusplus/runner.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ ENV PATH="$PATH:/out"
ENV AFL_SKIP_CPUFREQ=1
ENV AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1
ENV AFL_TESTCACHE_SIZE=2
RUN apt install -y unzip git gdb joe
106 changes: 106 additions & 0 deletions fuzzers/fishpp_new_exp/builder.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ARG parent_image
FROM $parent_image

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC

RUN apt-get update && \
apt-get install -y \
build-essential \
python3-dev \
python3-setuptools \
automake \
cmake \
git \
flex \
bison \
libglib2.0-dev \
libpixman-1-dev \
cargo \
libgtk-3-dev \
# for QEMU mode
ninja-build \
gcc-$(gcc --version|head -n1|sed 's/\..*//'|sed 's/.* //')-plugin-dev \
libstdc++-$(gcc --version|head -n1|sed 's/\..*//'|sed 's/.* //')-dev

RUN apt install -y git gcc g++ make cmake wget \
libgmp-dev libmpfr-dev texinfo bison python3

RUN apt-get install -y libboost-all-dev libjsoncpp-dev libgraphviz-dev \
pkg-config libglib2.0-dev findutils

RUN apt install -y lsb-release wget software-properties-common python3-pip

# these two packages are automatically installed, libpcap will consider libnl
# installed and try to link with libnl-genl-3-dev, which is not installed.
# Simply remove these packages
RUN apt remove libnl-3-200 libnl-3-dev -y

RUN pip3 install networkx pydot

# copy Fish++ earlier to patch the llvm
# COPY FishFuzz/FF_AFL++ /FishFuzz
RUN git clone https://github.com/kdsjZh/Fishpp/ /FishFuzz && \
cd /FishFuzz && git checkout c8858efe55908ec43152750d1015a38598e07240

# build clang-12 with gold plugin
RUN mkdir -p /build && \
git clone \
https://github.com/llvm/llvm-project /llvm && \
git clone \
--depth 1 \
--branch binutils-2_40-branch \
git://sourceware.org/git/binutils-gdb.git /llvm/binutils && \
cd /llvm/ && git checkout bf7f8d6fa6f460bf0a16ffec319cd71592216bf4 && \
git apply /FishFuzz/fish_mode/llvm_patch/llvm-15.0/llvm-15-asan.diff && \
cp /FishFuzz/fish_mode/llvm_patch/llvm-15.0/FishFuzzAddressSanitizer.cpp llvm/lib/Transforms/Instrumentation/ && \
mkdir /llvm/binutils/build && cd /llvm/binutils/build && \
CFLAGS="" CXXFLAGS="" CC=gcc CXX=g++ \
../configure --enable-gold --enable-plugins --disable-werror && \
make all-gold -j$(nproc) && \
cd /llvm/ && mkdir build && cd build &&\
CFLAGS="" CXXFLAGS="" CC=gcc CXX=g++ \
cmake -DCMAKE_BUILD_TYPE=Release \
-DLLVM_BINUTILS_INCDIR=/llvm/binutils/include \
-DLLVM_ENABLE_PROJECTS="compiler-rt;clang" \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" ../llvm && \
make -j$(nproc) && \
cp /llvm/build/lib/LLVMgold.so //usr/lib/bfd-plugins/ && \
cp /llvm/build/lib/libLTO.so //usr/lib/bfd-plugins/


ENV LLVM_CONFIG=llvm-config

# make sure our modified clang-12 is called before clang-15, which is in /usr/local/bin
ENV PATH="/llvm/build/bin:${PATH}"
ENV LD_LIBRARY_PATH="/llvm/build/lib/x86_64-unknown-linux-gnu/"


# Build without Python support as we don't need it.
# Set AFL_NO_X86 to skip flaky tests.
RUN cd /FishFuzz/ && \
unset CFLAGS CXXFLAGS CC CXX && \
export AFL_NO_X86=1 && \
make clean && \
PYTHON_INCLUDE=/ make && \
# make -C dyncfg && \
chmod +x fish_mode/distance/*.py && \
make install

RUN wget https://raw.githubusercontent.com/llvm/llvm-project/5feb80e748924606531ba28c97fe65145c65372e/compiler-rt/lib/fuzzer/afl/afl_driver.cpp -O /FishFuzz/afl_driver.cpp && \
clang++ -stdlib=libc++ -std=c++11 -O2 -c /FishFuzz/afl_driver.cpp -o /FishFuzz/afl_driver.o && \
ar r /libAFLDriver.a /FishFuzz/afl_driver.o /FishFuzz/afl-compiler-rt.o
Loading
Loading