From patchwork Fri Dec 17 13:19:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1570026 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RVv2U6cc; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFqN53NYdz9t6S for ; Sat, 18 Dec 2021 00:20:05 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 3F24F40BDA; Fri, 17 Dec 2021 13:20:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H3vSM0VPmLwF; Fri, 17 Dec 2021 13:20:01 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id BD69E40BA5; Fri, 17 Dec 2021 13:20:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 886C1C002F; Fri, 17 Dec 2021 13:20:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3D404C0038 for ; Fri, 17 Dec 2021 13:19:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id D5B58605AB for ; Fri, 17 Dec 2021 13:19:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=fail (1024-bit key) reason="fail (body has been altered)" header.d=redhat.com Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MRCW2-ZeUr-4 for ; Fri, 17 Dec 2021 13:19:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id E82AE610D6 for ; Fri, 17 Dec 2021 13:19:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639747167; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WUqP7otRoj/FkrAeVV6dQ1b8B0An5FGUZX/RsZmVPwg=; b=RVv2U6ccCx2drxnetm6FhRC3noS6u7xYYygn0ysMdqaWAHnC6JjIpUY7nqS5G02n3IFiVV r+xnu4kcNoowACw0wKVNNp0d5Iz8CLkathij4zkpT3MT7HVRlCTgclkAxgsiJuXrulFMKZ /v1ZhGXDAkjdnlrqvhwwyhlZT+MPJNU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-614-FMw7M1KSO_mFq2PH92SiVw-1; Fri, 17 Dec 2021 08:19:25 -0500 X-MC-Unique: FMw7M1KSO_mFq2PH92SiVw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C8AE41023F4D; Fri, 17 Dec 2021 13:19:24 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.193.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4501610A7; Fri, 17 Dec 2021 13:19:23 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Fri, 17 Dec 2021 14:19:18 +0100 Message-Id: <20211217131916.30994.9967.stgit@dceara.remote.csb> In-Reply-To: <20211217131623.30994.63519.stgit@dceara.remote.csb> References: <20211217131623.30994.63519.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH 11/11] ci: Add UB Sanitizer. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Signed-off-by: Dumitru Ceara --- .ci/linux-build.sh | 6 ++++++ .github/workflows/build-and-test.yml | 5 +++++ configure.ac | 1 + tests/atlocal.in | 16 ++++++++++++++++ tests/automake.mk | 1 + tests/daemon.at | 8 ++++++++ tests/ovs-macros.at | 5 +++++ tests/ovsdb-server.at | 16 ++++++++++++++++ 8 files changed, 58 insertions(+) diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh index ff6ae4b10031..5bdfc896bf0a 100755 --- a/.ci/linux-build.sh +++ b/.ci/linux-build.sh @@ -254,6 +254,12 @@ if [ "$ASAN" ]; then CFLAGS_FOR_OVS="${CFLAGS_FOR_OVS} ${CLFAGS_ASAN}" fi +if [ "$UBSAN" ]; then + # Use the default options configured in tests/atlocal.in, in UBSAN_OPTIONS. + CLFAGS_UBSAN="-O1 -fno-omit-frame-pointer -fno-common -fsanitize=undefined" + CFLAGS_FOR_OVS="${CFLAGS_FOR_OVS} ${CLFAGS_UBSAN}" +fi + save_OPTS="${OPTS} $*" OPTS="${EXTRA_OPTS} ${save_OPTS}" diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index eac3504e48f8..9e3583781baa 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -13,6 +13,7 @@ jobs: linux-headers-$(uname -r) build-essential fakeroot devscripts equivs AFXDP: ${{ matrix.afxdp }} ASAN: ${{ matrix.asan }} + UBSAN: ${{ matrix.ubsan }} CC: ${{ matrix.compiler }} DEB_PACKAGE: ${{ matrix.deb_package }} DPDK: ${{ matrix.dpdk }} @@ -44,6 +45,10 @@ jobs: testsuite: test kernel: 3.16 asan: asan + - compiler: clang + testsuite: test + kernel: 3.16 + ubsan: ubsan - compiler: gcc testsuite: test diff --git a/configure.ac b/configure.ac index eaa9bf7ee68a..8492824364a9 100644 --- a/configure.ac +++ b/configure.ac @@ -196,6 +196,7 @@ OVS_CHECK_LINUX_SCTP_CT OVS_CHECK_LINUX_VIRTIO_TYPES OVS_CHECK_DPDK OVS_CHECK_PRAGMA_MESSAGE +AC_SUBST([CFLAGS]) AC_SUBST([OVS_CFLAGS]) AC_SUBST([OVS_LDFLAGS]) diff --git a/tests/atlocal.in b/tests/atlocal.in index a0ad239ecef2..142ea2090bc8 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -4,6 +4,7 @@ OPENSSL_SUPPORTS_SNI='@OPENSSL_SUPPORTS_SNI@' HAVE_UNBOUND='@HAVE_UNBOUND@' EGREP='@EGREP@' PYTHON3='@PYTHON3@' +CFLAGS='@CFLAGS@' # PYTHONCOERCECLOCALE=0 disables the Unicode compatibility warning on # stderr that breaks almost any Python3 test (PEP 0538) @@ -197,6 +198,16 @@ else DIFF_SUPPORTS_NORMAL_FORMAT=no fi +# Check whether UB Sanitizer is being used. +case "$CFLAGS" in +*fsanitize=undefined*) + TESTS_WITH_UBSAN=yes + ;; +*) + TESTS_WITH_UBSAN=no + ;; +esac + # Turn off proxies. unset http_proxy unset https_proxy @@ -222,3 +233,8 @@ export OVS_CTL_TIMEOUT # matter break everything. ASAN_OPTIONS=detect_leaks=0:abort_on_error=true:log_path=asan:$ASAN_OPTIONS export ASAN_OPTIONS + +# Add some default flags for UndefinedBehaviorSanitizer, if it was used +# for the build. +UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=true:log_path=ubsan:$UBSAN_OPTIONS +export UBSAN_OPTIONS diff --git a/tests/automake.mk b/tests/automake.mk index 43731d097354..d1e787c10c76 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -213,6 +213,7 @@ check-local: set $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH); \ "$$@" $(TESTSUITEFLAGS) || \ (test -z "$$(find $(TESTSUITE_DIR) -name 'asan.*')" && \ + test -z "$$(find $(TESTSUITE_DIR) -name 'ubsan.*')" && \ test X'$(RECHECK)' = Xyes && "$$@" --recheck) # Python Coverage support. diff --git a/tests/daemon.at b/tests/daemon.at index 39d9aa391e9b..d7981f9d23a6 100644 --- a/tests/daemon.at +++ b/tests/daemon.at @@ -81,6 +81,10 @@ AT_SKIP_IF([test "$IS_WIN32" = "yes"]) # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS +# Skip it if UB Sanitizer is being used. There's no way to disable the +# SEGV check at runtime. +AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes]) + # Start the daemon and wait for the pidfile to get created. on_exit 'kill $(cat *.pid)' AT_CHECK([ovsdb-server --monitor --pidfile --no-db 2>/dev/null & echo $!], @@ -149,6 +153,10 @@ AT_SKIP_IF([test "$IS_WIN32" = "yes"]) # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS +# Skip it if UB Sanitizer is being used. There's no way to disable the +# SEGV check at runtime. +AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes]) + on_exit 'kill $(cat *.pid)' # Start the daemon and make sure that the pidfile exists immediately. diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at index 66545da5728f..7899583f3c21 100644 --- a/tests/ovs-macros.at +++ b/tests/ovs-macros.at @@ -216,6 +216,11 @@ ovs_cleanup() { cat asan.* AT_FAIL_IF([:]) fi + if test "$(echo ubsan.*)" != 'ubsan.*'; then + echo "Undefined Behavior Sanitizer reported errors in:" ubsan.* + cat ubsan.* + AT_FAIL_IF([:]) + fi } ovs_wait () { diff --git a/tests/ovsdb-server.at b/tests/ovsdb-server.at index 2b742f78b079..1e00be60684b 100644 --- a/tests/ovsdb-server.at +++ b/tests/ovsdb-server.at @@ -292,6 +292,10 @@ AT_SKIP_IF([test "$IS_WIN32" = "yes"]) # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS +# Skip it if UB Sanitizer is being used. There's no way to disable the +# SEGV check at runtime. +AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes]) + # Start ovsdb-server, initially with one db. ordinal_schema > schema AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore]) @@ -327,6 +331,10 @@ AT_SKIP_IF([test "$IS_WIN32" = "yes"]) # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS +# Skip it if UB Sanitizer is being used. There's no way to disable the +# SEGV check at runtime. +AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes]) + # Start ovsdb-server, initially with one db. ordinal_schema > schema AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore]) @@ -477,6 +485,10 @@ AT_SKIP_IF([test "$IS_WIN32" = "yes"]) # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS +# Skip it if UB Sanitizer is being used. There's no way to disable the +# SEGV check at runtime. +AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes]) + # Start ovsdb-server, initially with no remotes. ordinal_schema > schema AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) @@ -512,6 +524,10 @@ AT_SKIP_IF([test "$IS_WIN32" = "yes"]) # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS +# Skip it if UB Sanitizer is being used. There's no way to disable the +# SEGV check at runtime. +AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes]) + # Start ovsdb-server, initially with no remotes. ordinal_schema > schema AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])