Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
ff6a9ad
Add a few example setups of fuzzing campaigns
cyruscyliu May 29, 2025
0b0f455
Fix duration
cyruscyliu May 29, 2025
d8468b1
Merge pull request #1 from srividya-p/add-fuzzing-campaign-setup
srividya-p May 29, 2025
41bc470
Add gitignore
srividya-p Feb 25, 2025
91fb55f
Add script to generate target releases list
srividya-p Feb 25, 2025
1ce04c1
Add releases for libpng
srividya-p Feb 25, 2025
6130a12
Provide target version buildarg via captain
srividya-p Feb 25, 2025
acb0b0c
Add a generic script to fetch target by version
srividya-p Feb 25, 2025
224afe0
Use new fetch in Dockerfile
srividya-p Feb 25, 2025
d87c1c0
Move non applicable patches to failed dir (libpng)
srividya-p Feb 25, 2025
8b1be13
Remove libpng fetch.sh
srividya-p Feb 25, 2025
0238670
Update libsndfile to latest version
srividya-p Feb 25, 2025
a0dda27
Include gitlab links in fetch_target
srividya-p Feb 25, 2025
781d0eb
Generate libtiff releases
srividya-p Feb 25, 2025
28408cd
Update build.sh and remove fetch.sh
srividya-p Feb 25, 2025
0234650
Move libtiff bug patches to failed
srividya-p Feb 25, 2025
8a323b3
Update libtiff setup patch
srividya-p Feb 25, 2025
614c160
Generate releases libxml
srividya-p Feb 26, 2025
2638db6
Tag automake version libxml
srividya-p Feb 26, 2025
37e1558
Move patch files libxml
srividya-p Feb 26, 2025
d6b48ec
Update lua to latest version
srividya-p Feb 26, 2025
ed38f09
Generate openssl releases
srividya-p Feb 26, 2025
0074798
Update openssl version to latest
srividya-p Feb 26, 2025
cef5170
Categorize failed patched for PHP
srividya-p Apr 11, 2025
bf48db2
Categorize failed patches for poppler
srividya-p Apr 11, 2025
ec50eff
Generate releases for PHP and poppler
srividya-p Apr 11, 2025
951d8f6
Allow curl redirects for sqlite3 to fix existing build
srividya-p Apr 11, 2025
862e8ef
Move libsndfile.patch to graveyard
srividya-p Apr 22, 2025
ea0d018
Add step to fetch dependencies in Dockerfile (if present)
srividya-p Apr 23, 2025
ba4cd3b
Make fetch_target.sh nicer
srividya-p Apr 23, 2025
4185329
Initial update for scripts in PHP
srividya-p Apr 23, 2025
9c69ac9
Add MAGMA_DEBUG feature
srividya-p Apr 23, 2025
307a6cc
Allow magma user to use sudo
srividya-p Apr 23, 2025
5800308
Replace legacy ENV whitespace usage with =
srividya-p Apr 23, 2025
946d524
Remove debug containers after use
srividya-p Apr 23, 2025
968e4bb
DEBUG mount to workdir
srividya-p Apr 24, 2025
2db788b
Fix entrypoint
srividya-p Apr 24, 2025
429f50e
Fix setup patch for PHP latest version
srividya-p Apr 24, 2025
102aa63
Fix PHP build for latest version
srividya-p Apr 24, 2025
ec398e1
Move libxml2 setup patch to graveyard
srividya-p Apr 24, 2025
0c709e4
Move LLVM_VER to a variable in AFL++
srividya-p Apr 25, 2025
c5f4c02
Fix typo
srividya-p Apr 30, 2025
809d802
Upgrade honggfuzz clang to 16
srividya-p Apr 30, 2025
5a7b9a4
Ensure canary.h is ignored while compiling .S files in targets
srividya-p Apr 30, 2025
06890e1
Update poppler to the latest version
srividya-p Apr 30, 2025
e1af77b
Upgrade afl++ to 4.07c (clang and llvm to 16)
srividya-p Apr 30, 2025
b0314ad
Disable afl++ cmplog with PHP to fix build
srividya-p Apr 30, 2025
2fc49c3
Clean up tars in PHP
srividya-p Apr 30, 2025
60bf580
Classify sqlite3 patches
srividya-p Apr 30, 2025
6189f0b
Generate releases for sqlite3
srividya-p Apr 30, 2025
b7b673b
Fix sqlite3 build
srividya-p Apr 30, 2025
4a15bd6
Include pioneer stable commit in gen target releases
srividya-p May 2, 2025
50be27f
Move all targets to start of year commit
srividya-p May 2, 2025
4984c84
Clean up some TODOs
srividya-p May 3, 2025
7c505de
Update libfuzzer clang to 16
srividya-p May 3, 2025
afb4330
Use libc++ over libstdc++ to build libfuzzer
srividya-p May 3, 2025
5984002
Make libfuzzer fetch more efficient and pull latest
srividya-p May 3, 2025
5623e6c
Minor fixe and cleanup
srividya-p May 22, 2025
3090387
Remove fetch_deps.sh in PHP + move cloning onigiruma to preinstall
srividya-p May 22, 2025
3a1721c
Make fetching targets faster
srividya-p May 22, 2025
42a0efb
Update Dockerfile to 24.04
srividya-p May 23, 2025
8c63209
Update afl++ for Ubuntu 24.04
srividya-p May 23, 2025
62b9c02
Update all targets for Ubuntu 24.04
srividya-p May 23, 2025
fd86685
Tag afl++ to 2025 commit
srividya-p May 23, 2025
00f4d52
Update honggfuzz for Ubuntu 24.04
srividya-p May 24, 2025
4cb95b5
Update libfuzzer for Ubuntu 24.04
srividya-p May 24, 2025
626f931
Specify start and end years in gen target releases in a nicer way
srividya-p May 29, 2025
077e679
Port bugs for libpng
srividya-p May 2, 2025
293937a
Port bugs for lua
srividya-p May 3, 2025
94e5e60
Fix placeholder in PNG002
srividya-p May 3, 2025
f66823d
Port bugs for openssl
srividya-p May 3, 2025
df34e16
Port bugs for poppler
srividya-p May 3, 2025
95a945d
Port bugs for sqlite3
srividya-p May 4, 2025
8db709e
Port 3 bugs for libtff
srividya-p May 5, 2025
4b542d1
Port bugs for PHP
srividya-p May 5, 2025
68b1ddd
Add some more details in sqlite3 graveyard patches
srividya-p May 7, 2025
579c792
Flag deprecated libxml2 bugs
srividya-p May 8, 2025
e0d27c6
Port bugs for libxml
srividya-p May 11, 2025
6b2d564
Port bugs for libtiff
srividya-p May 11, 2025
cbb7929
Fix canary in TIF003
srividya-p May 21, 2025
6544b6e
Annotate magma_core build stage in Dockerfile
srividya-p May 24, 2025
0369cba
Add scripts to spin up PoC run containers
srividya-p May 24, 2025
21d1dd4
Call PoC run.sh from main run.sh if POC_MODE=1
srividya-p May 24, 2025
f6c59d5
Exit on empty POC_TARGETS
srividya-p May 24, 2025
5fef6ec
Update apply_patches to allow applying one patch only
srividya-p May 24, 2025
e271f05
Comtinue on empty bugs
srividya-p May 24, 2025
beb7d73
Add the build PoC stage in Dockerfile
srividya-p May 24, 2025
27dab04
Add PoC config for libtiff
srividya-p May 24, 2025
a1765cc
Add build_poc script and crash inputs for libtiff
srividya-p May 24, 2025
2d3127e
Update build_poc.sh for poppler
srividya-p May 24, 2025
4f8d652
Add crashes and config for poppler
srividya-p May 24, 2025
dbbeec6
Init PoC build for libpng
srividya-p May 24, 2025
46e7e3b
Init PoC build for libsndfile
srividya-p May 24, 2025
c198fbf
Init PoC build for libxml2
srividya-p May 24, 2025
e74f718
Init PoC build for lua
srividya-p May 24, 2025
1125712
Init PoC build for openssl
srividya-p May 24, 2025
8eaa024
Init PoC build for php
srividya-p May 24, 2025
9e09a6b
Init PoC build for sqlite3
srividya-p May 24, 2025
a032d51
Add PoC for LUA002
srividya-p May 27, 2025
6bd717d
Add a Poc for SQL018
srividya-p May 27, 2025
d4d2d7a
Update libpng build PoC
srividya-p May 27, 2025
d327ddf
Add PoC for SND001
srividya-p May 27, 2025
c61612c
Add PoC for PHP011
srividya-p May 28, 2025
c0a24d2
Merge pull request #2 from srividya-p/feat/srividya-add-poc-functiona…
srividya-p May 29, 2025
79cb404
Collect source-based code coverage
cyruscyliu Jun 1, 2025
b16b6bc
Add gen_cov_html.py
cyruscyliu Jun 1, 2025
1bdd4f2
Add coverage overtime
cyruscyliu Jun 3, 2025
c2772ae
Sample testcases for coverage one per minute
cyruscyliu Jun 11, 2025
972c57c
Fix data override and use median instead of mean
cyruscyliu Jun 11, 2025
f50c8ff
Fix a few bugs when collecting coverage
cyruscyliu Jun 11, 2025
b7e91ae
For libfuzzer, sync corpus seeds' timestamps
cyruscyliu Jun 12, 2025
d74e1ce
Auto expand polls=("$MONITOR"/*)
cyruscyliu Jul 2, 2025
df5f76e
Add y labels for coverage over time figures
cyruscyliu Jul 2, 2025
aab0f7a
Lint gen_cov + add cache option
srividya-p Jul 17, 2025
21b1eaf
Add option to build plots for specific targets
srividya-p Jul 17, 2025
3fc9977
Lint cov_overtime
srividya-p Jul 17, 2025
75238c0
Gen cov HTML minor script improvements
srividya-p Jul 18, 2025
a73d2b8
Attempt 1: Interpolate overtime data with numpy
srividya-p Jul 22, 2025
1dc9293
Allow specifiying multiple targets
srividya-p Jul 22, 2025
c4bff18
Allow specifying outfile name
srividya-p Jul 22, 2025
80eadf9
Fix openssl build with SOURCE_COVERAGE
srividya-p Jul 25, 2025
34977df
Check if profdata files are valid before merging
srividya-p Jul 25, 2025
8d1e16d
Organize scripts better in tools
srividya-p Aug 21, 2025
db55602
Export plotly graphs to images ot make cov report static
srividya-p Aug 22, 2025
d92f8e4
Add poppler pocs
Aug 22, 2025
8676c46
Add poppler pocs
Aug 22, 2025
8c982fd
target: add lua pocs
saralux48 Aug 22, 2025
5a8f1e5
target: add libtiff pocs
saralux48 Aug 22, 2025
b93c8de
Added commands for new libtiff pocs
saralux48 Aug 22, 2025
41e0339
Added command for new lua poc
saralux48 Aug 22, 2025
df5ef8d
Added commands for new poppler pocs
saralux48 Aug 22, 2025
d96b1b4
Update gitignore
srividya-p Sep 25, 2025
f301d10
Port report_df scripts to python 3.12
srividya-p Sep 25, 2025
5613cab
Link cov reports to main reprts
srividya-p Sep 25, 2025
373f232
Input duration and triald for benchmarking data
srividya-p Sep 25, 2025
e90d811
Merge pull request #3 from srividya-p/add-source-based-code-coverage
srividya-p Sep 25, 2025
2c0a5ab
Remove stray patch comment
srividya-p Jul 25, 2025
4b898d7
Bump requirements min version
srividya-p Sep 25, 2025
73a320a
Update version in report
srividya-p Sep 25, 2025
ce0ca6f
Merge pull request #4 from srividya-p/patch/srividya-bugfixes-poc-and…
srividya-p Sep 25, 2025
463e991
target: add poc for PDF002
saralux48 Sep 26, 2025
5e2d063
target: add poc for PDF010
saralux48 Sep 26, 2025
a31c9a3
target: add poc for PDF014
saralux48 Sep 26, 2025
dd2a620
target: add poc for PDF021
saralux48 Sep 26, 2025
5de10a8
Merge pull request #5 from saralux48/sara-add-pocs
cyruscyliu Sep 26, 2025
46fae20
Add MD report generation for cov
srividya-p Sep 29, 2025
13548f0
Follow file naming convention
srividya-p Sep 29, 2025
1bcf254
Add documentation for report generation
srividya-p Sep 29, 2025
8986e89
Rename README
srividya-p Sep 29, 2025
27d2e86
Make prints better
srividya-p Sep 29, 2025
da6d109
Remove deprecations
srividya-p Sep 29, 2025
fd6a9aa
Update coverage template
srividya-p Sep 29, 2025
7d1222f
Merge pull request #6 from srividya-p/feat/make-cov-pretty
cyruscyliu Sep 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
workdir*
__pycache__/
tools/benchd/*.json
tools/report_df/out/
cov_out/
*.pkl
*.html
126 changes: 99 additions & 27 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM ubuntu:18.04
##
# Stage: build core magma
##
FROM ubuntu:24.04 AS magma_core

# TODO remove sudo for user "magma" to avoid unwanted priv escalation from
# other attack vectors.
Expand All @@ -11,32 +14,34 @@ RUN apt-get update && apt-get install -y sudo
ARG magma_root=./

## Path variables inside the container
ENV MAGMA_R /magma
ENV OUT /magma_out
ENV SHARED /magma_shared

ENV CC /usr/bin/gcc
ENV CXX /usr/bin/g++
ENV LD /usr/bin/ld
ENV AR /usr/bin/ar
ENV AS /usr/bin/as
ENV NM /usr/bin/nm
ENV RANLIB /usr/bin/ranlib

ARG USER_ID=1000
ARG GROUP_ID=1000
ENV MAGMA_R=/magma
ENV OUT=/magma_out
ENV COV=/magma_cov
ENV SHARED=/magma_shared

ENV CC=/usr/bin/gcc
ENV CXX=/usr/bin/g++
ENV LD=/usr/bin/ld
ENV AR=/usr/bin/ar
ENV AS=/usr/bin/as
ENV NM=/usr/bin/nm
ENV RANLIB=/usr/bin/ranlib

ARG USER_ID=1001
ARG GROUP_ID=1001
RUN mkdir -p /home && \
groupadd -g ${GROUP_ID} magma && \
useradd -l -u ${USER_ID} -K UMASK=0000 -d /home -g magma magma && \
chown magma:magma /home
RUN echo "magma:amgam" | chpasswd && usermod -a -G sudo magma
RUN echo "magma ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers

RUN mkdir -p ${SHARED} ${OUT} && \
chown magma:magma ${SHARED} ${OUT} && \
chmod 744 ${SHARED} ${OUT}
RUN mkdir -p ${SHARED} ${OUT} ${COV} && \
chown magma:magma ${SHARED} ${OUT} ${COV} && \
chmod 744 ${SHARED} ${OUT} ${COV}

ARG magma_path=magma
ENV MAGMA ${MAGMA_R}/${magma_path}
ENV MAGMA=${MAGMA_R}/${magma_path}
USER root:root
RUN mkdir -p ${MAGMA} && chown magma:magma ${MAGMA}
COPY --chown=magma:magma ${magma_root}/${magma_path} ${MAGMA}/
Expand All @@ -46,24 +51,28 @@ RUN ${MAGMA}/prebuild.sh

ARG fuzzer_name
ARG fuzzer_path=fuzzers/${fuzzer_name}
ENV FUZZER ${MAGMA_R}/${fuzzer_path}
ENV FUZZER=${MAGMA_R}/${fuzzer_path}
USER root:root
RUN mkdir -p ${FUZZER} && chown magma:magma ${FUZZER}
COPY --chown=magma:magma ${magma_root}/${fuzzer_path} ${FUZZER}/
RUN ${FUZZER}/preinstall.sh
USER magma:magma
RUN ${FUZZER}/fetch.sh
RUN ${FUZZER}/build.sh
RUN if [ -f ${FUZZER}/postinstall.sh ]; then /bin/bash ${FUZZER}/postinstall.sh; fi

ARG target_name
ARG target_path=targets/${target_name}
ENV TARGET ${MAGMA_R}/${target_path}
ENV TARGET_NAME=${target_name}
ENV TARGET=${MAGMA_R}/${target_path}
ARG target_version
ENV TARGET_VERSION=${target_version}
USER root:root
RUN mkdir -p ${TARGET} && chown magma:magma ${TARGET}
COPY --chown=magma:magma ${magma_root}/${target_path} ${TARGET}/
RUN ${TARGET}/preinstall.sh
USER magma:magma
RUN ${TARGET}/fetch.sh
RUN ${MAGMA}/fetch_target.sh
RUN ${MAGMA}/apply_patches.sh

## Configuration parameters
Expand All @@ -78,11 +87,74 @@ ARG CANARIES_FLAG=${canaries:+-DMAGMA_ENABLE_CANARIES}
ARG FIXES_FLAG=${fixes:+-DMAGMA_ENABLE_FIXES}
ARG BUILD_FLAGS="-include ${MAGMA}/src/canary.h ${CANARIES_FLAG} ${FIXES_FLAG} ${ISAN_FLAG} ${HARDEN_FLAG} -g -O0"

ENV CFLAGS ${BUILD_FLAGS}
ENV CXXFLAGS ${BUILD_FLAGS}
ENV LIBS -l:magma.o -lrt
ENV LDFLAGS -L"${OUT}" -g
ENV CFLAGS=${BUILD_FLAGS}
ENV CXXFLAGS=${BUILD_FLAGS}
ENV LIBS="-l:magma.o -lrt"
ENV LDFLAGS="-L${OUT} -g"

ARG source_coverage
ENV SOURCE_COVERAGE=${source_coverage:+1}
ENV SOURCE_COVERAGE_FLAGS=${source_coverage:+"-fprofile-instr-generate -fcoverage-mapping"}

RUN ${FUZZER}/instrument.sh

ENTRYPOINT "${MAGMA}/run.sh"
ENTRYPOINT ["/bin/bash", "-c", "${MAGMA}/run.sh"]


##
# Stage: build magma PoCs
##
FROM ubuntu:24.04 AS magma_pocs

RUN apt-get update && apt-get install -y sudo g++ git

ARG magma_root=./
ARG poc_target_name
ARG poc_target_version
ARG poc_bug
ENV MAGMA_R=/magma
ENV OUT=/magma_out
ENV CC=/usr/bin/gcc
ENV CXX=/usr/bin/g++

# set up user and group
ARG USER_ID=1001
ARG GROUP_ID=1001

RUN mkdir -p /home && \
groupadd -g ${GROUP_ID} magma && \
useradd -l -u ${USER_ID} -K UMASK=0000 -d /home -g magma magma && \
chown magma:magma /home
RUN echo "magma:amgam" | chpasswd && usermod -a -G sudo magma
RUN echo "magma ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers

RUN mkdir -p ${OUT} && chown magma:magma ${OUT} && chmod 744 ${OUT}

# copy over magma source code
ARG magma_path=magma
ENV MAGMA=${MAGMA_R}/${magma_path}

USER root:root
RUN mkdir -p ${MAGMA} && chown magma:magma ${MAGMA}
COPY --chown=magma:magma ${magma_root}/${magma_path} ${MAGMA}/

# build a clean install of the target with a specific bug
ARG target_path=targets/${poc_target_name}
ENV TARGET_NAME=${poc_target_name}
ENV TARGET=${MAGMA_R}/${target_path}
ENV TARGET_VERSION=${poc_target_version}
ENV BUG_PATH=${TARGET}/patches/bugs/${poc_bug}.patch

USER root:root
RUN mkdir -p ${TARGET} && chown magma:magma ${TARGET}
COPY --chown=magma:magma ${magma_root}/${target_path} ${TARGET}/
RUN ${TARGET}/preinstall.sh
RUN ${MAGMA}/fetch_target.sh
RUN ${MAGMA}/apply_patches.sh ${BUG_PATH}
RUN ${TARGET}/build_poc.sh

# copy over the PoC input
ARG CRASH_CONTAINER_PATH=/test/crash_input
ARG CRASH_INPUT_PATH=${magma_root}/${target_path}/pocs/${poc_bug}.crash

COPY --chown=magma:magma ${CRASH_INPUT_PATH} ${CRASH_CONTAINER_PATH}
2 changes: 1 addition & 1 deletion fuzzers/aflplusplus/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ export PYTHON_INCLUDE=/
make -j$(nproc) || exit 1
make -C utils/aflpp_driver || exit 1

mkdir -p "$OUT/afl" "$OUT/cmplog"
mkdir -p "$OUT/afl" "$OUT/cmplog" "$COV/afl"
12 changes: 12 additions & 0 deletions fuzzers/aflplusplus/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e

##
# Pre-requirements:
# - env SHARED: path to directory shared with host (to store results)
##

export DIRECTORY_TO_SEARCH=$SHARED/findings/default/queue
chmod -R o+rx $SHARED/findings/default
export PATTERN_TO_MATCH="id:*"
cp $COV/afl/$PROGRAM $COV
13 changes: 8 additions & 5 deletions fuzzers/aflplusplus/fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ set -e
# - env FUZZER: path to fuzzer work dir
##

# Currently points to the first commit of 2025
AFLPLUSPLUS_STABLE_HASH=1ddfb1fec2b8aa99886a5de35c07e8f2a7bd8b98

git clone --no-checkout https://github.com/AFLplusplus/AFLplusplus "$FUZZER/repo"
git -C "$FUZZER/repo" checkout 458eb0813a6f7d63eed97f18696bca8274533123
git -C "$FUZZER/repo" checkout $AFLPLUSPLUS_STABLE_HASH

# Fix: CMake-based build systems fail with duplicate (of main) or undefined references (of LLVMFuzzerTestOneInput)
sed -i '{s/^int main/__attribute__((weak)) &/}' $FUZZER/repo/utils/aflpp_driver/aflpp_driver.c
Expand All @@ -24,15 +27,15 @@ EOF
patch -p1 -d "$FUZZER/repo" << EOF
--- a/utils/aflpp_driver/aflpp_driver.c
+++ b/utils/aflpp_driver/aflpp_driver.c
@@ -53,7 +53,7 @@
#include "hash.h"
@@ -65,7 +65,7 @@
#endif

// AFL++ shared memory fuzz cases
-int __afl_sharedmem_fuzzing = 1;
+int __afl_sharedmem_fuzzing = 0;
extern unsigned int * __afl_fuzz_len;
extern unsigned int *__afl_fuzz_len;
extern unsigned char *__afl_fuzz_ptr;

@@ -111,7 +111,8 @@ extern unsigned int * __afl_fuzz_len;
__attribute__((weak)) int LLVMFuzzerInitialize(int *argc, char ***argv);

Expand Down
14 changes: 14 additions & 0 deletions fuzzers/aflplusplus/instrument.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ set -e
# - env TARGET: path to target work dir
# - env MAGMA: path to Magma support files
# - env OUT: path to directory where artifacts are stored
# - env SOURCE_COVERAGE: if source-based code coverage is enabled
# - env COV: path to directory where artifacts for source-base code coverage are stored
# - env CFLAGS and CXXFLAGS must be set to link against Magma instrumentation
##

Expand All @@ -18,6 +20,7 @@ export LIBS="$LIBS -lc++ -lc++abi $FUZZER/repo/utils/aflpp_driver/libAFLDriver.a

# AFL++'s driver is compiled against libc++
export CXXFLAGS="$CXXFLAGS -stdlib=libc++"
export LDFLAGS="$LDFLAGS -stdlib=libc++"

# Build the AFL-only instrumented version
(
Expand All @@ -44,3 +47,14 @@ export CXXFLAGS="$CXXFLAGS -stdlib=libc++"
# NOTE: We pass $OUT directly to the target build.sh script, since the artifact
# itself is the fuzz target. In the case of Angora, we might need to
# replace $OUT by $OUT/fast and $OUT/track, for instance.

if [ ! -z $SOURCE_COVERAGE ]; then
export CC=clang
export CXX=clang++
export CFLAGS="$SOURCE_COVERAGE_FLAGS"
export CXXFLAGS="$SOURCE_COVERAGE_FLAGS"
export LDFLAGS="$SOURCE_COVERAGE_FLAGS"
export LIBS=""
export LIB_FUZZING_ENGINE="-fsanitize=fuzzer"
OUT=$COV/afl TARGET=$COV "$TARGET/build.sh"
fi
59 changes: 32 additions & 27 deletions fuzzers/aflplusplus/preinstall.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
#!/bin/bash
set -e

export LLVM_VERSION=16

apt-get update && \
apt-get install -y make clang-9 llvm-9-dev libc++-9-dev libc++abi-9-dev \
build-essential git wget gcc-7-plugin-dev
apt-get install -y make build-essential git wget \
clang-$LLVM_VERSION llvm-$LLVM_VERSION-dev \
libc++-$LLVM_VERSION-dev libc++abi-$LLVM_VERSION-dev \
gcc-$(gcc --version|head -n1|sed 's/\..*//'|sed 's/.* //')-plugin-dev

update-alternatives \
--install /usr/lib/llvm llvm /usr/lib/llvm-9 20 \
--slave /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-9 \
--slave /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-9 \
--slave /usr/bin/llvm-as llvm-as /usr/bin/llvm-as-9 \
--slave /usr/bin/llvm-bcanalyzer llvm-bcanalyzer /usr/bin/llvm-bcanalyzer-9 \
--slave /usr/bin/llvm-c-test llvm-c-test /usr/bin/llvm-c-test-9 \
--slave /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-9 \
--slave /usr/bin/llvm-diff llvm-diff /usr/bin/llvm-diff-9 \
--slave /usr/bin/llvm-dis llvm-dis /usr/bin/llvm-dis-9 \
--slave /usr/bin/llvm-dwarfdump llvm-dwarfdump /usr/bin/llvm-dwarfdump-9 \
--slave /usr/bin/llvm-extract llvm-extract /usr/bin/llvm-extract-9 \
--slave /usr/bin/llvm-link llvm-link /usr/bin/llvm-link-9 \
--slave /usr/bin/llvm-mc llvm-mc /usr/bin/llvm-mc-9 \
--slave /usr/bin/llvm-nm llvm-nm /usr/bin/llvm-nm-9 \
--slave /usr/bin/llvm-objdump llvm-objdump /usr/bin/llvm-objdump-9 \
--slave /usr/bin/llvm-ranlib llvm-ranlib /usr/bin/llvm-ranlib-9 \
--slave /usr/bin/llvm-readobj llvm-readobj /usr/bin/llvm-readobj-9 \
--slave /usr/bin/llvm-rtdyld llvm-rtdyld /usr/bin/llvm-rtdyld-9 \
--slave /usr/bin/llvm-size llvm-size /usr/bin/llvm-size-9 \
--slave /usr/bin/llvm-stress llvm-stress /usr/bin/llvm-stress-9 \
--slave /usr/bin/llvm-symbolizer llvm-symbolizer /usr/bin/llvm-symbolizer-9 \
--slave /usr/bin/llvm-tblgen llvm-tblgen /usr/bin/llvm-tblgen-9
--install /usr/lib/llvm llvm /usr/lib/llvm-$LLVM_VERSION 20 \
--slave /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-$LLVM_VERSION \
--slave /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-$LLVM_VERSION \
--slave /usr/bin/llvm-as llvm-as /usr/bin/llvm-as-$LLVM_VERSION \
--slave /usr/bin/llvm-bcanalyzer llvm-bcanalyzer /usr/bin/llvm-bcanalyzer-$LLVM_VERSION \
--slave /usr/bin/llvm-c-test llvm-c-test /usr/bin/llvm-c-test-$LLVM_VERSION \
--slave /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-$LLVM_VERSION \
--slave /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-$LLVM_VERSION \
--slave /usr/bin/llvm-diff llvm-diff /usr/bin/llvm-diff-$LLVM_VERSION \
--slave /usr/bin/llvm-dis llvm-dis /usr/bin/llvm-dis-$LLVM_VERSION \
--slave /usr/bin/llvm-dwarfdump llvm-dwarfdump /usr/bin/llvm-dwarfdump-$LLVM_VERSION \
--slave /usr/bin/llvm-extract llvm-extract /usr/bin/llvm-extract-$LLVM_VERSION \
--slave /usr/bin/llvm-link llvm-link /usr/bin/llvm-link-$LLVM_VERSION \
--slave /usr/bin/llvm-mc llvm-mc /usr/bin/llvm-mc-$LLVM_VERSION \
--slave /usr/bin/llvm-nm llvm-nm /usr/bin/llvm-nm-$LLVM_VERSION \
--slave /usr/bin/llvm-objdump llvm-objdump /usr/bin/llvm-objdump-$LLVM_VERSION \
--slave /usr/bin/llvm-ranlib llvm-ranlib /usr/bin/llvm-ranlib-$LLVM_VERSION \
--slave /usr/bin/llvm-readobj llvm-readobj /usr/bin/llvm-readobj-$LLVM_VERSION \
--slave /usr/bin/llvm-rtdyld llvm-rtdyld /usr/bin/llvm-rtdyld-$LLVM_VERSION \
--slave /usr/bin/llvm-size llvm-size /usr/bin/llvm-size-$LLVM_VERSION \
--slave /usr/bin/llvm-stress llvm-stress /usr/bin/llvm-stress-$LLVM_VERSION \
--slave /usr/bin/llvm-symbolizer llvm-symbolizer /usr/bin/llvm-symbolizer-$LLVM_VERSION \
--slave /usr/bin/llvm-tblgen llvm-tblgen /usr/bin/llvm-tblgen-$LLVM_VERSION

update-alternatives \
--install /usr/bin/clang clang /usr/bin/clang-9 20 \
--slave /usr/bin/clang++ clang++ /usr/bin/clang++-9 \
--slave /usr/bin/clang-cpp clang-cpp /usr/bin/clang-cpp-9
--install /usr/bin/clang clang /usr/bin/clang-$LLVM_VERSION 20 \
--slave /usr/bin/clang++ clang++ /usr/bin/clang++-$LLVM_VERSION \
--slave /usr/bin/clang-cpp clang-cpp /usr/bin/clang-cpp-$LLVM_VERSION
8 changes: 7 additions & 1 deletion fuzzers/aflplusplus/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ fi

mkdir -p "$SHARED/findings"

flag_cmplog=(-m none -c "$OUT/cmplog/$PROGRAM")
# TODO: Figure out why cmplog gets stuck infinitely on PHP
if [[ "$TARGET" == */php ]]; then
flag_cmplog=()
else
flag_cmplog=(-m none -c "$OUT/cmplog/$PROGRAM")
fi

export AFL_SKIP_CPUFREQ=1
export AFL_NO_AFFINITY=1
export AFL_NO_UI=1
export AFL_MAP_SIZE=256000
export AFL_DRIVER_DONT_DEFER=1
export AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1

"$FUZZER/repo/afl-fuzz" -i "$TARGET/corpus/$PROGRAM" -o "$SHARED/findings" \
"${flag_cmplog[@]}" -d \
Expand Down
4 changes: 4 additions & 0 deletions fuzzers/aflplusplus/runonce.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# - env OUT: path to directory where artifacts are stored
# - env PROGRAM: name of program to run (should be found in $OUT)
# - env ARGS: extra arguments to pass to the program
# - env SOURCE_COVERAGE: if source-based code coverage is enabled
##

export TIMELIMIT=0.1s
Expand All @@ -24,5 +25,8 @@ if [ -z "$args" ]; then
args="'$1'"
fi

if [ ! -z $SOURCE_COVERAGE ]; then
export LD_PRELOAD=$OUT/source_coverage.so
fi
timeout -s KILL --preserve-status $TIMELIMIT bash -c \
"run_limited '$OUT/afl/$PROGRAM' $args"
11 changes: 11 additions & 0 deletions fuzzers/honggfuzz/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e

##
# Pre-requirements:
# - env SHARED: path to directory shared with host (to store results)
##

export DIRECTORY_TO_SEARCH=$SHARED/output
chmod -R o+rx $SHARED/output
export PATTERN_TO_MATCH="*"
Loading