[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 27/31] fuzz: add configure flag --enable-fuzzing
From: |
Stefan Hajnoczi |
Subject: |
[PULL 27/31] fuzz: add configure flag --enable-fuzzing |
Date: |
Sat, 22 Feb 2020 08:50:26 +0000 |
From: Alexander Bulekov <address@hidden>
Signed-off-by: Alexander Bulekov <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Darren Kenny <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
configure | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/configure b/configure
index d57261e3ad..48d6f89d57 100755
--- a/configure
+++ b/configure
@@ -505,6 +505,7 @@ debug_mutex="no"
libpmem=""
default_devices="yes"
plugins="no"
+fuzzing="no"
supported_cpu="no"
supported_os="no"
@@ -635,6 +636,15 @@ int main(void) { return 0; }
EOF
}
+write_c_fuzzer_skeleton() {
+ cat > $TMPC <<EOF
+#include <stdint.h>
+#include <sys/types.h>
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
+EOF
+}
+
if check_define __linux__ ; then
targetos="Linux"
elif check_define _WIN32 ; then
@@ -1558,6 +1568,10 @@ for opt do
;;
--disable-containers) use_containers="no"
;;
+ --enable-fuzzing) fuzzing=yes
+ ;;
+ --disable-fuzzing) fuzzing=no
+ ;;
*)
echo "ERROR: unknown option $opt"
echo "Try '$0 --help' for more information"
@@ -6072,6 +6086,15 @@ EOF
fi
fi
+##########################################
+# checks for fuzzer
+if test "$fuzzing" = "yes" ; then
+ write_c_fuzzer_skeleton
+ if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address,fuzzer" ""; then
+ have_fuzzer=yes
+ fi
+fi
+
##########################################
# check for libpmem
@@ -6666,6 +6689,7 @@ echo "libpmem support $libpmem"
echo "libudev $libudev"
echo "default devices $default_devices"
echo "plugin support $plugins"
+echo "fuzzing support $fuzzing"
if test "$supported_cpu" = "no"; then
echo
@@ -7504,6 +7528,16 @@ fi
if test "$sheepdog" = "yes" ; then
echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
fi
+if test "$fuzzing" = "yes" ; then
+ if test "$have_fuzzer" = "yes"; then
+ FUZZ_LDFLAGS=" -fsanitize=address,fuzzer"
+ FUZZ_CFLAGS=" -fsanitize=address,fuzzer"
+ CFLAGS=" -fsanitize=address,fuzzer-no-link"
+ else
+ error_exit "Your compiler doesn't support -fsanitize=address,fuzzer"
+ exit 1
+ fi
+fi
if test "$plugins" = "yes" ; then
echo "CONFIG_PLUGIN=y" >> $config_host_mak
@@ -7605,6 +7639,11 @@ if test "$libudev" != "no"; then
echo "CONFIG_LIBUDEV=y" >> $config_host_mak
echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
fi
+if test "$fuzzing" != "no"; then
+ echo "CONFIG_FUZZ=y" >> $config_host_mak
+ echo "FUZZ_CFLAGS=$FUZZ_CFLAGS" >> $config_host_mak
+ echo "FUZZ_LDFLAGS=$FUZZ_LDFLAGS" >> $config_host_mak
+fi
if test "$edk2_blobs" = "yes" ; then
echo "DECOMPRESS_EDK2_BLOBS=y" >> $config_host_mak
--
2.24.1
- [PULL 19/31] libqos: split qos-test and libqos makefile vars, (continued)
- [PULL 19/31] libqos: split qos-test and libqos makefile vars, Stefan Hajnoczi, 2020/02/22
- [PULL 21/31] fuzz: add fuzzer skeleton, Stefan Hajnoczi, 2020/02/22
- [PULL 20/31] libqos: move useful qos-test funcs to qos_external, Stefan Hajnoczi, 2020/02/22
- [PULL 22/31] exec: keep ram block across fork when using qtest, Stefan Hajnoczi, 2020/02/22
- [PULL 23/31] main: keep rcu_atfork callback enabled for qtest, Stefan Hajnoczi, 2020/02/22
- [PULL 24/31] fuzz: support for fork-based fuzzing., Stefan Hajnoczi, 2020/02/22
- [PULL 25/31] fuzz: add support for qos-assisted fuzz targets, Stefan Hajnoczi, 2020/02/22
- [PULL 26/31] fuzz: add target/fuzz makefile rules, Stefan Hajnoczi, 2020/02/22
- [PULL 27/31] fuzz: add configure flag --enable-fuzzing,
Stefan Hajnoczi <=
- [PULL 28/31] fuzz: add i440fx fuzz targets, Stefan Hajnoczi, 2020/02/22
- [PULL 29/31] fuzz: add virtio-net fuzz target, Stefan Hajnoczi, 2020/02/22
- [PULL 30/31] fuzz: add virtio-scsi fuzz target, Stefan Hajnoczi, 2020/02/22
- [PULL 31/31] fuzz: add documentation to docs/devel/, Stefan Hajnoczi, 2020/02/22
- Re: [PULL 00/31] Block patches, no-reply, 2020/02/22
- Re: [PULL 00/31] Block patches, Peter Maydell, 2020/02/24