aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Vereshchagin <evvers@ya.ru>2021-03-25 17:30:32 +0300
committerGitHub <noreply@github.com>2021-03-25 07:30:32 -0700
commit0efca5f4f4432d75dbf602cf8cfafd23267abf8e (patch)
treecc010ab26e158c645f470dd93e96713157a3c461
parent6019f6a7127ae857ae4b5bdf377aa7ba8714cd0c (diff)
downloadoss-fuzz-0efca5f4f4432d75dbf602cf8cfafd23267abf8e.tar.gz
[lxc] initial integration (#5498)
-rw-r--r--projects/lxc/Dockerfile22
-rwxr-xr-xprojects/lxc/build.sh43
-rw-r--r--projects/lxc/fuzz-lxc-config-read.c41
-rw-r--r--projects/lxc/project.yaml12
4 files changed, 118 insertions, 0 deletions
diff --git a/projects/lxc/Dockerfile b/projects/lxc/Dockerfile
new file mode 100644
index 000000000..3d581d4cd
--- /dev/null
+++ b/projects/lxc/Dockerfile
@@ -0,0 +1,22 @@
+# Copyright 2021 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/oss-fuzz-base/base-builder
+RUN apt-get update && \
+ apt-get install -y pkgconf make libtool automake autoconf
+RUN git clone --depth 1 https://github.com/lxc/lxc
+WORKDIR lxc
+COPY build.sh *.c $SRC/
diff --git a/projects/lxc/build.sh b/projects/lxc/build.sh
new file mode 100755
index 000000000..9f41c6cfe
--- /dev/null
+++ b/projects/lxc/build.sh
@@ -0,0 +1,43 @@
+#!/bin/bash -e
+# Copyright 2021 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.
+#
+################################################################################
+
+# -fsanitize=... isn't compatible with -Wl,-no-undefined
+# https://github.com/google/sanitizers/issues/380
+sed -i 's/-Wl,-no-undefined *\\/\\/' src/lxc/Makefile.am
+
+# AFL++ and hoggfuzz are both incompatible with lto=thin apparently
+sed -i '/-flto=thin/d' configure.ac
+
+# turn off the libutil dependency
+sed -i 's/^AC_CHECK_LIB(util/#/' configure.ac
+
+./autogen.sh
+./configure \
+ --disable-tools \
+ --disable-commands \
+ --disable-apparmor \
+ --disable-openssl \
+ --disable-selinux \
+ --disable-seccomp \
+ --disable-capabilities
+
+make -j$(nproc)
+
+$CC -c -o fuzz-lxc-config-read.o $CFLAGS -Isrc -Isrc/lxc $SRC/fuzz-lxc-config-read.c
+$CXX $CXXFLAGS $LIB_FUZZING_ENGINE fuzz-lxc-config-read.o src/lxc/.libs/liblxc.a -o $OUT/fuzz-lxc-config-read
+
+zip -r $OUT/fuzz-lxc-config-read_seed_corpus.zip doc/examples
diff --git a/projects/lxc/fuzz-lxc-config-read.c b/projects/lxc/fuzz-lxc-config-read.c
new file mode 100644
index 000000000..27d1e5528
--- /dev/null
+++ b/projects/lxc/fuzz-lxc-config-read.c
@@ -0,0 +1,41 @@
+/*
+# Copyright 2021 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.
+#
+################################################################################
+*/
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "conf.h"
+#include "confile.h"
+#include "utils.h"
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ int fd = -1;
+ char tmpf[] = "fuzz-lxc-config-read-XXXXXX";
+ struct lxc_conf *conf = NULL;
+
+ fd = lxc_make_tmpfile(tmpf, false);
+ lxc_write_nointr(fd, data, size);
+ close(fd);
+
+ conf = lxc_conf_init();
+ lxc_config_read(tmpf, conf, false);
+ lxc_conf_free(conf);
+
+ (void) unlink(tmpf);
+ return 0;
+}
diff --git a/projects/lxc/project.yaml b/projects/lxc/project.yaml
new file mode 100644
index 000000000..e77622315
--- /dev/null
+++ b/projects/lxc/project.yaml
@@ -0,0 +1,12 @@
+homepage: "https://github.com/lxc/lxc"
+language: c
+primary_contact: "christian.brauner@ubuntu.com"
+builds_per_day: 4
+sanitizers:
+ - address
+ - undefined
+ - memory
+auto_ccs:
+ - stgraber@ubuntu.com
+ - evverx@gmail.com
+main_repo: "https://github.com/lxc/lxc"