commit 1b244a64e403f9b6bd452d1f2e9c961a1f91e2d7 Author: Nick Mathewson nickm@torproject.org Date: Mon Jan 9 10:44:55 2017 -0500
libfuzzer tweaks per recommendations --- Makefile.am | 3 +- configure.ac | 5 +++- src/test/fuzz/include.am | 78 +++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 83 insertions(+), 3 deletions(-)
diff --git a/Makefile.am b/Makefile.am index 785cf34..631b44e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,7 +56,8 @@ TEST_NETWORK_FLAGS=--hs-multi-client 1 endif
if LIBFUZZER_ENABLED -TEST_CFLAGS += -fsanitize-coverage=edge -fsanitize-coverage=trace-cmp +TEST_CFLAGS += -fsanitize-coverage=trace-pc-guard,trace-cmp,trace-div +# not "edge" endif
TEST_NETWORK_ALL_LOG_DIR=$(top_builddir)/test_network_log diff --git a/configure.ac b/configure.ac index 784b3cd..aff41ae 100644 --- a/configure.ac +++ b/configure.ac @@ -50,7 +50,9 @@ AC_ARG_ENABLE(asserts-in-tests, AC_ARG_ENABLE(system-torrc, AS_HELP_STRING(--disable-system-torrc, [don't look for a system-wide torrc file])) AC_ARG_ENABLE(libfuzzer, - AS_HELP_STRING(--libfuzzer, [build extra fuzzers based on 'libfuzzer'])) + AS_HELP_STRING(--enable-libfuzzer, [build extra fuzzers based on 'libfuzzer'])) +AC_ARG_ENABLE(oss-fuzz, + AS_HELP_STRING(--enable-oss-fuzz, [build extra fuzzers based on 'oss-fuzz' environment]))
if test "x$enable_coverage" != "xyes" -a "x$enable_asserts_in_tests" = "xno" ; then AC_MSG_ERROR([Can't disable assertions outside of coverage build]) @@ -60,6 +62,7 @@ AM_CONDITIONAL(UNITTESTS_ENABLED, test "x$enable_unittests" != "xno") AM_CONDITIONAL(COVERAGE_ENABLED, test "x$enable_coverage" = "xyes") AM_CONDITIONAL(DISABLE_ASSERTS_IN_UNIT_TESTS, test "x$enable_asserts_in_tests" = "xno") AM_CONDITIONAL(LIBFUZZER_ENABLED, test "x$enable_libfuzzer" = "xyes") +AM_CONDITIONAL(OSS_FUZZ_ENABLED, test "x$enable_oss_fuzz" = "xyes")
if test "$enable_static_tor" = "yes"; then enable_static_libevent="yes"; diff --git a/src/test/fuzz/include.am b/src/test/fuzz/include.am index 2bfdaf3..bb92c87 100644 --- a/src/test/fuzz/include.am +++ b/src/test/fuzz/include.am @@ -175,6 +175,82 @@ else LIBFUZZER_FUZZERS = endif
-noinst_PROGRAMS += $(FUZZERS) $(LIBFUZZER_FUZZERS) +if OSS_FUZZ_ENABLED +OSS_FUZZ_CPPFLAGS = $(FUZZING_CPPFLAGS) -DLLVM_FUZZ +OSS_FUZZ_CFLAGS = $(FUZZING_CFLAGS) +OSS_FUZZ_LDFLAG = $(FUZZING_LDFLAG) +OSS_FUZZ_LIBS = $(FUZZING_LIBS) -lFuzzingEngine -lstdc++ + +src_test_fuzz_oss_fuzz_consensus_SOURCES = \ + $(src_test_fuzz_fuzz_consensus_SOURCES) +src_test_fuzz_oss_fuzz_consensus_CPPFLAGS = $(OSS_FUZZ_CPPFLAGS) +src_test_fuzz_oss_fuzz_consensus_CFLAGS = $(OSS_FUZZ_CFLAGS) +src_test_fuzz_oss_fuzz_consensus_LDFLAGS = $(OSS_FUZZ_LDFLAG) +src_test_fuzz_oss_fuzz_consensus_LDADD = $(OSS_FUZZ_LIBS) + +src_test_fuzz_oss_fuzz_descriptor_SOURCES = \ + $(src_test_fuzz_fuzz_descriptor_SOURCES) +src_test_fuzz_oss_fuzz_descriptor_CPPFLAGS = $(OSS_FUZZ_CPPFLAGS) +src_test_fuzz_oss_fuzz_descriptor_CFLAGS = $(OSS_FUZZ_CFLAGS) +src_test_fuzz_oss_fuzz_descriptor_LDFLAGS = $(OSS_FUZZ_LDFLAG) +src_test_fuzz_oss_fuzz_descriptor_LDADD = $(OSS_FUZZ_LIBS) + +src_test_fuzz_oss_fuzz_extrainfo_SOURCES = \ + $(src_test_fuzz_fuzz_extrainfo_SOURCES) +src_test_fuzz_oss_fuzz_extrainfo_CPPFLAGS = $(OSS_FUZZ_CPPFLAGS) +src_test_fuzz_oss_fuzz_extrainfo_CFLAGS = $(OSS_FUZZ_CFLAGS) +src_test_fuzz_oss_fuzz_extrainfo_LDFLAGS = $(OSS_FUZZ_LDFLAG) +src_test_fuzz_oss_fuzz_extrainfo_LDADD = $(OSS_FUZZ_LIBS) + +src_test_fuzz_oss_fuzz_http_SOURCES = \ + $(src_test_fuzz_fuzz_http_SOURCES) +src_test_fuzz_oss_fuzz_http_CPPFLAGS = $(OSS_FUZZ_CPPFLAGS) +src_test_fuzz_oss_fuzz_http_CFLAGS = $(OSS_FUZZ_CFLAGS) +src_test_fuzz_oss_fuzz_http_LDFLAGS = $(OSS_FUZZ_LDFLAG) +src_test_fuzz_oss_fuzz_http_LDADD = $(OSS_FUZZ_LIBS) + +src_test_fuzz_oss_fuzz_hsdescv2_SOURCES = \ + $(src_test_fuzz_fuzz_hsdescv2_SOURCES) +src_test_fuzz_oss_fuzz_hsdescv2_CPPFLAGS = $(OSS_FUZZ_CPPFLAGS) +src_test_fuzz_oss_fuzz_hsdescv2_CFLAGS = $(OSS_FUZZ_CFLAGS) +src_test_fuzz_oss_fuzz_hsdescv2_LDFLAGS = $(OSS_FUZZ_LDFLAG) +src_test_fuzz_oss_fuzz_hsdescv2_LDADD = $(OSS_FUZZ_LIBS) + +src_test_fuzz_oss_fuzz_iptsv2_SOURCES = \ + $(src_test_fuzz_fuzz_iptsv2_SOURCES) +src_test_fuzz_oss_fuzz_iptsv2_CPPFLAGS = $(OSS_FUZZ_CPPFLAGS) +src_test_fuzz_oss_fuzz_iptsv2_CFLAGS = $(OSS_FUZZ_CFLAGS) +src_test_fuzz_oss_fuzz_iptsv2_LDFLAGS = $(OSS_FUZZ_LDFLAG) +src_test_fuzz_oss_fuzz_iptsv2_LDADD = $(OSS_FUZZ_LIBS) + +src_test_fuzz_oss_fuzz_microdesc_SOURCES = \ + $(src_test_fuzz_fuzz_microdesc_SOURCES) +src_test_fuzz_oss_fuzz_microdesc_CPPFLAGS = $(OSS_FUZZ_CPPFLAGS) +src_test_fuzz_oss_fuzz_microdesc_CFLAGS = $(OSS_FUZZ_CFLAGS) +src_test_fuzz_oss_fuzz_microdesc_LDFLAGS = $(OSS_FUZZ_LDFLAG) +src_test_fuzz_oss_fuzz_microdesc_LDADD = $(OSS_FUZZ_LIBS) + +src_test_fuzz_oss_fuzz_vrs_SOURCES = \ + $(src_test_fuzz_fuzz_vrs_SOURCES) +src_test_fuzz_oss_fuzz_vrs_CPPFLAGS = $(OSS_FUZZ_CPPFLAGS) +src_test_fuzz_oss_fuzz_vrs_CFLAGS = $(OSS_FUZZ_CFLAGS) +src_test_fuzz_oss_fuzz_vrs_LDFLAGS = $(OSS_FUZZ_LDFLAG) +src_test_fuzz_oss_fuzz_vrs_LDADD = $(OSS_FUZZ_LIBS) + +OSS_FUZZ_FUZZERS = \ + src/test/fuzz/oss-fuzz-consensus \ + src/test/fuzz/oss-fuzz-descriptor \ + src/test/fuzz/oss-fuzz-extrainfo \ + src/test/fuzz/oss-fuzz-http \ + src/test/fuzz/oss-fuzz-hsdescv2 \ + src/test/fuzz/oss-fuzz-iptsv2 \ + src/test/fuzz/oss-fuzz-microdesc \ + src/test/fuzz/oss-fuzz-vrs +else +OSS_FUZZ_FUZZERS +endif + +noinst_PROGRAMS += $(FUZZERS) $(LIBFUZZER_FUZZERS) $(OSS_FUZZ_FUZZERS) +oss-fuzz-fuzzers: $(OSS_FUZZ_FUZZERS) fuzzers: $(FUZZERS) $(LIBFUZZER_FUZZERS)