Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions benchmark/asn1/3bd5319-patch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM prosyslab/bug-bench-base

RUN apt-get -y update
RUN apt-get -y install wget autoconf texinfo \
git make autoconf automake libtool

ENV PROGRAM=asn1
ENV VERSION=3bd5319

RUN mkdir $PROGRAM

ENV URL=https://github.com/openssl/openssl.git
ENV TAG_NAME="3bd5319"

RUN git clone $URL $PROGRAM

WORKDIR $PROGRAM
RUN git reset --hard $TAG_NAME

RUN git clone --depth 1 --branch v1.2 https://github.com/HexHive/magma.git /tmp/magma && \
for patch_file in /tmp/magma/targets/openssl/patches/bugs/*.patch; do \
name=${patch_file##*/} && \
name=${name%.patch} && \
sed "s/%MAGMA_BUG%/$name/g" "$patch_file" | patch -p1; \
done && \
cp -r /tmp/magma/magma/src ../magma_src && \
rm -rf /tmp/magma

COPY canary.c $SRC/magma_src/
COPY afl_driver.cpp $SRC/magma_src/

COPY build.sh $SRC
31 changes: 31 additions & 0 deletions benchmark/asn1/3bd5319-patch/afl_driver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

extern "C" {

__attribute__((weak))
extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size);
__attribute__((weak))
extern int LLVMFuzzerInitialize(int *argc, char ***argv);
__attribute__((weak))
int main(int argc, char **argv) {
if (LLVMFuzzerInitialize)
LLVMFuzzerInitialize(&argc, &argv);
for (int i = 1; i < argc; i++) {
FILE *f = fopen(argv[i], "r");
assert(f);
fseek(f, 0, SEEK_END);
size_t len = ftell(f);
fseek(f, 0, SEEK_SET);
unsigned char *buf = (unsigned char*)malloc(len);
size_t n_read = fread(buf, 1, len, f);
fclose(f);
assert(n_read == len);
LLVMFuzzerTestOneInput(buf, len);
free(buf);
}
return 0;
}

}
37 changes: 37 additions & 0 deletions benchmark/asn1/3bd5319-patch/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
SMAKE_I_DIR="sparrow/fuzz"
BIN_PATH="fuzz/asn1"

if [[ $1 == "haechi" ]]; then
export CC=$GCLANG_BIN
export CFLAGS="$CFLAGS -include /src/magma_src/canary.h -DMAGMA_ENABLE_CANARIES -g -O0"
export CFLAGS_FOR_CONFIG=$CFLAGS
export CFLAGS="$CFLAGS -fno-discard-value-names -Xclang -disable-O0-optnone"

export CXX=$GCLANG_BIN++
export CXXFLAGS="$CXXFLAGS -include /src/magma_src/canary.h -DMAGMA_ENABLE_CANARIES -g -O0"

# Copied from magma/fuzzers/vanilla/build.sh
$CXX $CXXFLAGS -std=c++11 -c "/src/magma_src/afl_driver.cpp" -fPIC \
-o "/src/magma_src/afl_driver.o"
$CC $CFLAGS -c /src/magma_src/canary.c -o /src/magma_src/canary.o

export LIBS="$LIBS /src/magma_src/afl_driver.o /src/magma_src/canary.o -lstdc++"
export LDLIBS="$LIBS"
./config --debug enable-fuzz-libfuzzer enable-fuzz-afl disable-tests -DPEDANTIC \
-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION no-shared no-module \
enable-tls1_3 enable-rc5 enable-md2 enable-ec_nistp_64_gcc_128 enable-ssl3 \
enable-ssl3-method enable-nextprotoneg enable-weak-ssl-ciphers \
$CFLAGS_FOR_CONFIG -fno-sanitize=alignment

$SMAKE_BIN --init
$SMAKE_BIN -j LDCMD="$CXX $CXXFLAGS"
cp $SMAKE_I_DIR/*.i $SMAKE_OUT

$GET_BC_BIN $BIN_PATH &&
llvm-dis -o $BIN_PATH.ll $BIN_PATH.bc &&
opt -mem2reg -S -o $HAECHI_OUT/$(basename $BIN_PATH).ll $BIN_PATH.ll
else
echo "Unknown build target"
exit 1
fi
4 changes: 4 additions & 0 deletions benchmark/asn1/3bd5319-patch/canary.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void magma_log(const char *bug, int condition) {
(void)bug;
(void)condition;
}
1 change: 1 addition & 0 deletions benchmark/asn1/3bd5319-patch/label.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
32 changes: 32 additions & 0 deletions benchmark/libpng_read_fuzzer/a37d483-patch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM prosyslab/bug-bench-base

RUN apt-get -y update
RUN apt-get -y install wget git automake pkg-config python-is-python3 libtool autogen \
make autoconf zlib1g-dev

ENV PROGRAM=libpng_read_fuzzer
ENV VERSION=a37d483

RUN mkdir $PROGRAM

ENV URL=https://github.com/glennrp/libpng.git
ENV TAG_NAME="a37d483"

RUN git clone $URL $PROGRAM

WORKDIR $PROGRAM
RUN git reset --hard $TAG_NAME

RUN git clone --depth 1 --branch v1.2 https://github.com/HexHive/magma.git /tmp/magma && \
for patch_file in /tmp/magma/targets/libpng/patches/bugs/*.patch; do \
name=${patch_file##*/} && \
name=${name%.patch} && \
sed "s/%MAGMA_BUG%/$name/g" "$patch_file" | patch -p1; \
done && \
cp -r /tmp/magma/magma/src ../magma_src && \
rm -rf /tmp/magma

COPY canary.c $SRC/magma_src/
COPY afl_driver.cpp $SRC/magma_src/

COPY build.sh $SRC
31 changes: 31 additions & 0 deletions benchmark/libpng_read_fuzzer/a37d483-patch/afl_driver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

extern "C" {

__attribute__((weak))
extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size);
__attribute__((weak))
extern int LLVMFuzzerInitialize(int *argc, char ***argv);
__attribute__((weak))
int main(int argc, char **argv) {
if (LLVMFuzzerInitialize)
LLVMFuzzerInitialize(&argc, &argv);
for (int i = 1; i < argc; i++) {
FILE *f = fopen(argv[i], "r");
assert(f);
fseek(f, 0, SEEK_END);
size_t len = ftell(f);
fseek(f, 0, SEEK_SET);
unsigned char *buf = (unsigned char*)malloc(len);
size_t n_read = fread(buf, 1, len, f);
fclose(f);
assert(n_read == len);
LLVMFuzzerTestOneInput(buf, len);
free(buf);
}
return 0;
}

}
37 changes: 37 additions & 0 deletions benchmark/libpng_read_fuzzer/a37d483-patch/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
SMAKE_I_DIR="sparrow"
BIN_PATH="contrib/oss-fuzz/libpng_read_fuzzer"

if [[ $1 == "haechi" ]]; then
export CC=$GCLANG_BIN
export CFLAGS="$CFLAGS -include ../magma_src/canary.h -DMAGMA_ENABLE_CANARIES -g -O0"
export CFLAGS="$CFLAGS -fno-discard-value-names -Xclang -disable-O0-optnone"
export CXX=$GCLANG_BIN++
export CXXFLAGS="$CXXFLAGS -include ../magma_src/canary.h -DMAGMA_ENABLE_CANARIES -g -O0"
export CXXFLAGS="$CXXFLAGS -fno-discard-value-names -Xclang -disable-O0-optnone"

autoreconf -f -i
./configure --disable-shared

# Copied from magma/fuzzers/vanilla/build.sh
$CXX $CXXFLAGS -std=c++11 -c "/src/magma_src/afl_driver.cpp" -fPIC \
-o "/src/magma_src/afl_driver.o"
$CC $CFLAGS -c ../magma_src/canary.c -o ../magma_src/canary.o

$SMAKE_BIN --init
$SMAKE_BIN -j libpng16.la
cp $SMAKE_I_DIR/*.i $SMAKE_OUT

export LIBS="$LIBS /src/magma_src/afl_driver.o /src/magma_src/canary.o -lstdc++"
$CXX $CXXFLAGS -std=c++11 -I. -include cstdlib \
$BIN_PATH.cc \
-o $BIN_PATH \
.libs/libpng16.a $LIBS -lz

$GET_BC_BIN $BIN_PATH &&
llvm-dis -o $BIN_PATH.ll $BIN_PATH.bc &&
opt -mem2reg -S -o $HAECHI_OUT/$(basename $BIN_PATH).ll $BIN_PATH.ll
else
echo "Unknown build target"
exit 1
fi
4 changes: 4 additions & 0 deletions benchmark/libpng_read_fuzzer/a37d483-patch/canary.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void magma_log(const char *bug, int condition) {
(void)bug;
(void)condition;
}
1 change: 1 addition & 0 deletions benchmark/libpng_read_fuzzer/a37d483-patch/label.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
32 changes: 32 additions & 0 deletions benchmark/server/3bd5319-patch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM prosyslab/bug-bench-base

RUN apt-get -y update
RUN apt-get -y install wget autoconf texinfo \
git make autoconf automake libtool

ENV PROGRAM=server
ENV VERSION=3bd5319

RUN mkdir $PROGRAM

ENV URL=https://github.com/openssl/openssl.git
ENV TAG_NAME="3bd5319"

RUN git clone $URL $PROGRAM

WORKDIR $PROGRAM
RUN git reset --hard $TAG_NAME

RUN git clone --depth 1 --branch v1.2 https://github.com/HexHive/magma.git /tmp/magma && \
for patch_file in /tmp/magma/targets/openssl/patches/bugs/*.patch; do \
name=${patch_file##*/} && \
name=${name%.patch} && \
sed "s/%MAGMA_BUG%/$name/g" "$patch_file" | patch -p1; \
done && \
cp -r /tmp/magma/magma/src ../magma_src && \
rm -rf /tmp/magma

COPY canary.c $SRC/magma_src/
COPY afl_driver.cpp $SRC/magma_src/

COPY build.sh $SRC
31 changes: 31 additions & 0 deletions benchmark/server/3bd5319-patch/afl_driver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

extern "C" {

__attribute__((weak))
extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size);
__attribute__((weak))
extern int LLVMFuzzerInitialize(int *argc, char ***argv);
__attribute__((weak))
int main(int argc, char **argv) {
if (LLVMFuzzerInitialize)
LLVMFuzzerInitialize(&argc, &argv);
for (int i = 1; i < argc; i++) {
FILE *f = fopen(argv[i], "r");
assert(f);
fseek(f, 0, SEEK_END);
size_t len = ftell(f);
fseek(f, 0, SEEK_SET);
unsigned char *buf = (unsigned char*)malloc(len);
size_t n_read = fread(buf, 1, len, f);
fclose(f);
assert(n_read == len);
LLVMFuzzerTestOneInput(buf, len);
free(buf);
}
return 0;
}

}
37 changes: 37 additions & 0 deletions benchmark/server/3bd5319-patch/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
SMAKE_I_DIR="sparrow/fuzz"
BIN_PATH="fuzz/server"

if [[ $1 == "haechi" ]]; then
export CC=$GCLANG_BIN
export CFLAGS="$CFLAGS -include /src/magma_src/canary.h -DMAGMA_ENABLE_CANARIES -g -O0"
export CFLAGS_FOR_CONFIG=$CFLAGS
export CFLAGS="$CFLAGS -fno-discard-value-names -Xclang -disable-O0-optnone"

export CXX=$GCLANG_BIN++
export CXXFLAGS="$CXXFLAGS -include /src/magma_src/canary.h -DMAGMA_ENABLE_CANARIES -g -O0"

# Copied from magma/fuzzers/vanilla/build.sh
$CXX $CXXFLAGS -std=c++11 -c "/src/magma_src/afl_driver.cpp" -fPIC \
-o "/src/magma_src/afl_driver.o"
$CC $CFLAGS -c /src/magma_src/canary.c -o /src/magma_src/canary.o

export LIBS="$LIBS /src/magma_src/afl_driver.o /src/magma_src/canary.o -lstdc++"
export LDLIBS="$LIBS"
./config --debug enable-fuzz-libfuzzer enable-fuzz-afl disable-tests -DPEDANTIC \
-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION no-shared no-module \
enable-tls1_3 enable-rc5 enable-md2 enable-ec_nistp_64_gcc_128 enable-ssl3 \
enable-ssl3-method enable-nextprotoneg enable-weak-ssl-ciphers \
$CFLAGS_FOR_CONFIG -fno-sanitize=alignment

$SMAKE_BIN --init
$SMAKE_BIN -j LDCMD="$CXX $CXXFLAGS"
cp $SMAKE_I_DIR/*.i $SMAKE_OUT

$GET_BC_BIN $BIN_PATH &&
llvm-dis -o $BIN_PATH.ll $BIN_PATH.bc &&
opt -mem2reg -S -o $HAECHI_OUT/$(basename $BIN_PATH).ll $BIN_PATH.ll
else
echo "Unknown build target"
exit 1
fi
4 changes: 4 additions & 0 deletions benchmark/server/3bd5319-patch/canary.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void magma_log(const char *bug, int condition) {
(void)bug;
(void)condition;
}
1 change: 1 addition & 0 deletions benchmark/server/3bd5319-patch/label.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
33 changes: 33 additions & 0 deletions benchmark/sndfile_fuzzer/86c9f9e-patch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM prosyslab/bug-bench-base

RUN apt-get -y update
RUN apt-get -y install wget git automake pkg-config python-is-python3 libtool autogen


ENV PROGRAM=sndfile_fuzzer
ENV VERSION=86c9f9e

RUN mkdir $PROGRAM

ENV URL=https://github.com/libsndfile/libsndfile.git
ENV TAG_NAME="86c9f9e"

RUN git clone $URL $PROGRAM

WORKDIR $PROGRAM
RUN git reset --hard $TAG_NAME

RUN git clone --depth 1 --branch v1.2 https://github.com/HexHive/magma.git /tmp/magma && \
patch -p1 -i /tmp/magma/targets/libsndfile/patches/setup/libsndfile.patch && \
for patch_file in /tmp/magma/targets/libsndfile/patches/bugs/*.patch; do \
name=${patch_file##*/} && \
name=${name%.patch} && \
sed "s/%MAGMA_BUG%/$name/g" "$patch_file" | patch -p1; \
done && \
cp -r /tmp/magma/magma/src ../magma_src && \
rm -rf /tmp/magma

COPY canary.c $SRC/magma_src/
COPY afl_driver.cpp $SRC/magma_src/

COPY build.sh $SRC
Loading