-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
278e74e
commit 8c57315
Showing
5 changed files
with
125 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 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 | ||
|
||
# honggfuzz requires libfd and libunwid. | ||
RUN apt-get update -y && \ | ||
apt-get install -y \ | ||
libbfd-dev \ | ||
libunwind-dev \ | ||
libblocksruntime-dev \ | ||
liblzma-dev | ||
|
||
# Download honggfuz version 2.3.1 + 0b4cd5b1c4cf26b7e022dc1deb931d9318c054cb | ||
# Set CFLAGS use honggfuzz's defaults except for -mnative which can build CPU | ||
# dependent code that may not work on the machines we actually fuzz on. | ||
# Create an empty object file which will become the FUZZER_LIB lib (since | ||
# honggfuzz doesn't need this when hfuzz-clang(++) is used). | ||
RUN git clone https://github.com/google/honggfuzz.git /honggfuzz && \ | ||
cd /honggfuzz && \ | ||
git checkout oss-fuzz && \ | ||
CFLAGS="-O3 -funroll-loops" make && \ | ||
touch empty_lib.c && \ | ||
cc -c -o empty_lib.o empty_lib.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# 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. | ||
"""Integration code for Honggfuzz fuzzer.""" | ||
|
||
import os | ||
import shutil | ||
import subprocess | ||
|
||
from fuzzers import utils | ||
|
||
|
||
def build(): | ||
"""Build benchmark.""" | ||
# honggfuzz doesn't need additional libraries when code is compiled | ||
# with hfuzz-clang(++) | ||
os.environ['CC'] = '/honggfuzz/hfuzz_cc/hfuzz-clang' | ||
os.environ['CXX'] = '/honggfuzz/hfuzz_cc/hfuzz-clang++' | ||
os.environ['FUZZER_LIB'] = '/honggfuzz/empty_lib.o' | ||
|
||
utils.build_benchmark() | ||
|
||
print('[post_build] Copying honggfuzz to $OUT directory') | ||
# Copy over honggfuzz's main fuzzing binary. | ||
shutil.copy('/honggfuzz/honggfuzz', os.environ['OUT']) | ||
|
||
|
||
def fuzz(input_corpus, output_corpus, target_binary): | ||
"""Run fuzzer.""" | ||
# Seperate out corpus and crash directories as sub-directories of | ||
# |output_corpus| to avoid conflicts when corpus directory is reloaded. | ||
crashes_dir = os.path.join(output_corpus, 'crashes') | ||
output_corpus = os.path.join(output_corpus, 'corpus') | ||
os.makedirs(crashes_dir) | ||
os.makedirs(output_corpus) | ||
|
||
print('[fuzz] Running target with honggfuzz') | ||
command = [ | ||
'./honggfuzz', | ||
'--persistent', | ||
'--rlimit_rss', | ||
'2048', | ||
'--sanitizers_del_report=true', | ||
'--input', | ||
input_corpus, | ||
'--output', | ||
output_corpus, | ||
|
||
# Store crashes along with corpus for bug based benchmarking. | ||
'--crashdir', | ||
crashes_dir, | ||
] | ||
dictionary_path = utils.get_dictionary_path(target_binary) | ||
if dictionary_path: | ||
command.extend(['--dict', dictionary_path]) | ||
command.extend(['--', target_binary]) | ||
|
||
print('[fuzz] Running command: ' + ' '.join(command)) | ||
subprocess.check_call(command) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# 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. | ||
|
||
FROM gcr.io/fuzzbench/base-image | ||
|
||
# honggfuzz requires libfd and libunwid | ||
RUN apt-get update -y && apt-get install -y libbfd-dev libunwind-dev |