Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions .ci/docker.run
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause

set -eo pipefail
set -x

source $DOCKER_BUILD_DIR/.ci/docker-prelude.sh

Expand Down Expand Up @@ -37,9 +38,27 @@ fi

# Is it a fuzz run, if so build the fuzz test and exit.
if [ "$GEN_FUZZ" == "1" ]; then
./configure --with-fuzzing=libfuzzer --enable-tcti-fuzzing \
--disable-tcti-device --disable-tcti-mssim --disable-tcti-swtpm \
--disable-shared --with-crypto="$WITH_CRYPTO"
./configure \
--enable-debug \
--with-fuzzing=libfuzzer \
--enable-code-coverage\
--disable-esys \
--disable-fapi \
--enable-tcti-fuzzing \
--disable-tcti-cmd \
--disable-tcti-device\
--disable-tcti-i2c-ftdi \
--disable-tcti-libtpms\
--disable-tcti-mssim \
--disable-tcti-pcap\
--disable-tcti-spi-ftdi \
--disable-tcti-spi-ltt2go \
--disable-tcti-spidev \
--disable-tcti-start-sim \
--disable-tcti-swtpm \
--with-maxloglevel=none \
--disable-shared \
--with-crypto="$WITH_CRYPTO"
make -j$(nproc) check
exit 0
fi
Expand Down
36 changes: 25 additions & 11 deletions Makefile-fuzz.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@
# Copyright (c) 2019 Intel Corporation
# All rights reserved.

if ENABLE_FUZZING

TEST_EXTENSIONS += .fuzz
FUZZ_LOG_COMPILER = $(srcdir)/script/fuzz-log-compiler.sh
AM_TESTS_ENVIRONMENT = TPM20TEST_TCTI='$(INTEGRATION_TCTI)'
# Workaround so that we can use to pass arguments to the test (instead of the log compiler).
# Execute the last positional argument, passing all other positional arguments.
# What makes this even more cursed is Makefile escaping: $ -> $$, # -> \#
#
# e.g.
# bash -c '${@: $#} ${@: 0:$#}' -rss_limit_mb=1000 -runs=10000000 test/fuzz/Tss2_Sys_GetRandom.fuzz
# executes
# test/fuzz/Tss2_Sys_GetRandom.fuzz -rss_limit_mb=1000 -runs=10000000
FUZZ_LOG_COMPILER = bash -c '$${@: $$\#} $${@: 0:$$\#}'
AM_FUZZ_LOG_FLAGS = -error_exitcode=1 -timeout_exitcode=1 -max_total_time=1
INCLUDE_DIRS += -I$(srcdir)/test/fuzz/tcti
TESTS_LIBADD = $(lib_LTLIBRARIES) $(libtss2_mu) $(libtss2_sys) $(libutil)
TESTS_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/test/integration
TESTS_LDFLAGS = $(AM_LDFLAGS)
TESTS_LDADD += $(libtss2_utils_fuzzing)

EXTRA_DIST += test/fuzz/main-sys.c
# tcti library used for fuzzing
Expand All @@ -20,20 +35,18 @@ test_fuzz_tcti_libtss2_tcti_fuzzing_la_SOURCES = \
test/fuzz/tcti/tss2_tcti_fuzzing.h
endif # ENABLE_TCTI_FUZZING

if ENABLE_FUZZING
FUZZ_CFLAGS = $(TESTS_CFLAGS) -I$(srcdir)/test/integration
FUZZCFLAGS = $(FUZZ_CFLAGS) $(TESTS_CFLAGS) -I$(srcdir)/test/integration
FUZZ_CPPFLAGS = $(INCLUDE_DIRS) -I$(srcdir)/test/integration $(LIB_FUZZING_ENGINE)

libtss2_utils_fuzzing = test/fuzz/libfuzz_utils.la
check_LTLIBRARIES += $(libtss2_utils_fuzzing)
test_fuzz_libfuzz_utils_la_LDFLAGS = $(TESTS_LDFLAGS)
test_fuzz_libfuzz_utils_la_LIBADD = $(TESTS_LIBADD)
test_fuzz_libfuzz_utils_la_CFLAGS = $(AM_CFLAGS) $(FUZZ_CFLAGS)
test_fuzz_libfuzz_utils_la_LIBADD = $(TESTS_LIBADD) $(libtss2_tcti_fuzzing)
test_fuzz_libfuzz_utils_la_CFLAGS = $(TESTS_CFLAGS)
test_fuzz_libfuzz_utils_la_SOURCES = \
test/integration/test-common.c test/integration/test-common.h

TESTS_LDADD += $(libtss2_utils_fuzzing)
FUZZLDADD = $(TESTS_LDADD) $(TESTS_LDFLAGS) $(FUZZ_LDFLAGS)
test/integration/test-common-tcti.c test/integration/test-common-tcti.h \
test/integration/test-common.c test/integration/test-common.h \
src/util/log.c

fuzzdir = $(srcdir)
fuzz-targets: $(fuzz_PROGRAMS)
Expand All @@ -47,8 +60,9 @@ DISTCLEANFILES += Makefile-fuzz-generated.am

# Non Autogenerated Fuzz Tests
noinst_PROGRAMS += test/fuzz/tcti-spi-helper-fuzz-test
test_fuzz_tcti_spi_helper_fuzz_test_CFLAGS = $(FUZZ_CFLAGS) $(FUZZ_CFLAGS) $(AM_CFLAGS)
test_fuzz_tcti_spi_helper_fuzz_test_LDADD = $(FUZZLDADD)
test_fuzz_tcti_spi_helper_fuzz_test_CFLAGS = $(TESTS_CFLAGS)
test_fuzz_tcti_spi_helper_fuzz_test_LDFLAGS = $(TESTS_LDFLAGS)
test_fuzz_tcti_spi_helper_fuzz_test_LDADD = $(TESTS_LDADD) $(libtss2_tcti_spi_helper)
nodist_test_fuzz_tcti_spi_helper_fuzz_test_SOURCES = test/fuzz/tcti-spi-helper-fuzz-test.c

include Makefile-fuzz-generated.am
Expand Down
Loading
Loading