From b628847628d659f0fc9e78448b74f6dbda779730 Mon Sep 17 00:00:00 2001 From: Max Moroz Date: Fri, 16 Aug 2019 21:29:04 -0700 Subject: [PATCH] [syzkaller] Initial integration. (#2713) * [syzkaller] Initial integration. * clarify a comment * download pre-built go and build 3 fuzzers out of 5 --- projects/syzkaller/Dockerfile | 28 ++++++++++++++++++++ projects/syzkaller/build.sh | 45 +++++++++++++++++++++++++++++++++ projects/syzkaller/project.yaml | 7 +++++ 3 files changed, 80 insertions(+) create mode 100644 projects/syzkaller/Dockerfile create mode 100755 projects/syzkaller/build.sh create mode 100644 projects/syzkaller/project.yaml diff --git a/projects/syzkaller/Dockerfile b/projects/syzkaller/Dockerfile new file mode 100644 index 000000000..86a75533b --- /dev/null +++ b/projects/syzkaller/Dockerfile @@ -0,0 +1,28 @@ +# Copyright 2019 Google Inc. +# +# 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/oss-fuzz-base/base-builder +MAINTAINER mmoroz@chromium.org +ADD https://dl.google.com/go/go1.12.9.linux-amd64.tar.gz go.tar.gz +RUN tar xzf go.tar.gz -C $SRC/ +ENV GOPATH $SRC +ENV PATH $SRC/go/bin:$GOPATH/bin:$PATH + +RUN go get -u -d github.com/google/syzkaller/... + +RUN git clone --depth 1 https://github.com/google/syzkaller.git syzkaller +WORKDIR syzkaller +COPY build.sh $SRC/ diff --git a/projects/syzkaller/build.sh b/projects/syzkaller/build.sh new file mode 100755 index 000000000..d1f78311d --- /dev/null +++ b/projects/syzkaller/build.sh @@ -0,0 +1,45 @@ +#!/bin/bash -eu +# Copyright 2019 Google Inc. +# +# 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. +# +################################################################################ + +# Dependency of go-fuzz +go get golang.org/x/tools/go/packages + +# go-fuzz-build is the tool that instruments Go files. +go get github.com/dvyukov/go-fuzz/go-fuzz-build + +# Based on the function from oss-fuzz/projects/golang/build.sh script. +function compile_fuzzer { + path=$1 + function=$2 + fuzzer=$3 + + # Instrument all Go files relevant to this fuzzer + go-fuzz-build -libfuzzer -func $function -o $fuzzer.a $path + + # Instrumented, compiled Go ($fuzzer.a) + fuzzing engine = fuzzer binary + $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -lpthread -o $OUT/$fuzzer +} + +compile_fuzzer ./pkg/compiler Fuzz compiler_fuzzer +compile_fuzzer ./prog/test FuzzDeserialize prog_deserialize_fuzzer +compile_fuzzer ./prog/test FuzzParseLog prog_parselog_fuzzer + +# This target fails to build. +# compile_fuzzer ./pkg/report Fuzz report_fuzzer + +# This target is way too spammy and OOMs very quickly. +# compile_fuzzer ./tools/syz-trace2syz/proggen Fuzz trace2syz_fuzzer diff --git a/projects/syzkaller/project.yaml b/projects/syzkaller/project.yaml new file mode 100644 index 000000000..df62fb965 --- /dev/null +++ b/projects/syzkaller/project.yaml @@ -0,0 +1,7 @@ +homepage: "https://github.com/google/syzkaller.git" +primary_contact: "dvyukov@google.com" +auto_ccs: + - "andreyknvl@google.com" + - "mmoroz@chromium.org" +sanitizers: + - address