mirror of https://github.com/google/oss-fuzz.git
zydis: Add more fuzzer targets (#6827)
Additionally, set `max_len` for all targets for improved performance.
This commit is contained in:
parent
a40762cc08
commit
dea4017887
|
@ -1,4 +1,4 @@
|
||||||
# Copyright 2020 Google Inc.
|
# Copyright 2021 Google Inc.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -16,8 +16,12 @@
|
||||||
|
|
||||||
FROM gcr.io/oss-fuzz-base/base-builder
|
FROM gcr.io/oss-fuzz-base/base-builder
|
||||||
|
|
||||||
ADD https://github.com/zyantific/zydis/raw/master/assets/ZydisFuzz_seed_corpus.zip \
|
ADD https://zydis.re/fuzzing-corpora/ZydisFuzzDecoder_seed_corpus.zip \
|
||||||
$SRC/ZydisFuzz_seed_corpus.zip
|
$SRC/ZydisFuzzDecoder_seed_corpus.zip
|
||||||
|
ADD https://zydis.re/fuzzing-corpora/ZydisFuzzEncoder_seed_corpus.zip \
|
||||||
|
$SRC/ZydisFuzzEncoder_seed_corpus.zip
|
||||||
|
ADD https://zydis.re/fuzzing-corpora/ZydisFuzzReEncoding_seed_corpus.zip \
|
||||||
|
$SRC/ZydisFuzzReEncoding_seed_corpus.zip
|
||||||
|
|
||||||
COPY build.sh $SRC/
|
COPY build.sh $SRC/
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/bash -eu
|
#!/bin/bash -eu
|
||||||
# Copyright 2020 Google Inc.
|
#
|
||||||
|
# Copyright 2021 Google Inc.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -15,33 +16,58 @@
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
mv $SRC/ZydisFuzz_seed_corpus.zip $OUT/ZydisFuzz_seed_corpus.zip
|
set -eu
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build Zydis library.
|
||||||
|
#
|
||||||
|
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
|
|
||||||
cmake \
|
cmake \
|
||||||
-DZYAN_FORCE_ASSERTS=ON \
|
-DZYAN_FORCE_ASSERTS=ON \
|
||||||
-DZYDIS_BUILD_EXAMPLES=OFF \
|
-DZYDIS_BUILD_EXAMPLES=OFF \
|
||||||
-DZYDIS_BUILD_TOOLS=OFF \
|
-DZYDIS_BUILD_TOOLS=OFF \
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||||
-DCMAKE_C_COMPILER=$CC \
|
"-DCMAKE_C_COMPILER=${CC}" \
|
||||||
-DCMAKE_CXX_COMPILER=$CXX \
|
"-DCMAKE_CXX_COMPILER=${CXX}" \
|
||||||
-DCMAKE_C_FLAGS="$CFLAGS" \
|
"-DCMAKE_C_FLAGS=${CFLAGS}" \
|
||||||
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
|
"-DCMAKE_CXX_FLAGS=${CXXFLAGS}" \
|
||||||
..
|
..
|
||||||
|
|
||||||
make -j$(nproc) VERBOSE=1
|
make -j$(nproc) VERBOSE=1
|
||||||
|
|
||||||
$CXX \
|
#
|
||||||
$CXXFLAGS \
|
# Build fuzzing tools.
|
||||||
$LIB_FUZZING_ENGINE \
|
#
|
||||||
../tools/ZydisFuzzDecoder.c \
|
|
||||||
../tools/ZydisFuzzShared.c \
|
|
||||||
-DZYDIS_LIBFUZZER \
|
|
||||||
-o $OUT/ZydisFuzz \
|
|
||||||
-I . \
|
|
||||||
-I ./zycore \
|
|
||||||
-I ../include \
|
|
||||||
-I ../dependencies/zycore/include \
|
|
||||||
./libZydis.a
|
|
||||||
|
|
||||||
|
function build_fuzzer() {
|
||||||
|
source_file="${1}"
|
||||||
|
max_len="${2}"
|
||||||
|
executable="${source_file%.c}"
|
||||||
|
|
||||||
|
$CC \
|
||||||
|
$CFLAGS \
|
||||||
|
"${LIB_FUZZING_ENGINE}" \
|
||||||
|
"../tools/${source_file}" \
|
||||||
|
../tools/ZydisFuzzShared.c \
|
||||||
|
-DZYDIS_LIBFUZZER \
|
||||||
|
-o "${OUT}/${executable}" \
|
||||||
|
-I . \
|
||||||
|
-I ./zycore \
|
||||||
|
-I ../include \
|
||||||
|
-I ../dependencies/zycore/include \
|
||||||
|
./libZydis.a
|
||||||
|
|
||||||
|
echo -e "[libfuzzer]\nmax_len = ${max_len}" > "${OUT}/${executable}.options"
|
||||||
|
}
|
||||||
|
|
||||||
|
build_fuzzer "ZydisFuzzDecoder.c" 350
|
||||||
|
build_fuzzer "ZydisFuzzEncoder.c" 450
|
||||||
|
build_fuzzer "ZydisFuzzReEncoding.c" 100
|
||||||
|
|
||||||
|
#
|
||||||
|
# Place fuzzing corpora where they belong.
|
||||||
|
#
|
||||||
|
|
||||||
|
cp ${SRC}/Zydis*_seed_corpus.zip ${OUT}
|
||||||
|
|
Loading…
Reference in New Issue