From patchwork Sat Mar 24 01:58:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrick Wong X-Patchwork-Id: 890373 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="hSVXYARC"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 407Npl2T2Jz9s08 for ; Sat, 24 Mar 2018 12:58:07 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751848AbeCXB6G (ORCPT ); Fri, 23 Mar 2018 21:58:06 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:51454 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751758AbeCXB6G (ORCPT ); Fri, 23 Mar 2018 21:58:06 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2O1hLmZ023619; Sat, 24 Mar 2018 01:58:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=JRgsWVguvaS9NhGDRiPexSRR3Q5zq2dQI4vd6ZU1I5Y=; b=hSVXYARCq/L7BRlqGTd1OFX3ngYMeMPed+ZXNr0JKRmjxerNn8o6Pds+nQGH/kW2kveH bqujJIYf/9iKZRG9tY018xk50uqD3JaewKRWVmKLBa8r6M/HYnSA/f7W+8yj3n0WTR0q ZBugxDvTHjmSK2GeHxwqrsnMUxaWewWckpx644JpoQcvQPTp5FR9X+7uRmGXStGrq/bE FYzN/pypi7WCWwypfrXedt/HZdSD9d1sGACT6CIyzk/a9yBHINQ/qj0jvYTQ6qkUZt/f A6G6Mg7UXEUSMGP/jXKMnHSsQ+cb5xSS84Yxaca9XqQOVYHU60YuFqfty1ArGnFS7wrY 5w== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2gwd8rg0g4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 24 Mar 2018 01:58:04 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w2O1w2Wj026378 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 24 Mar 2018 01:58:03 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w2O1w2UJ024143; Sat, 24 Mar 2018 01:58:02 GMT Received: from localhost (/10.159.132.121) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 23 Mar 2018 18:58:02 -0700 Subject: [PATCH 4/5] misc: enable thread sanitizer if the builder wants it From: "Darrick J. Wong" To: tytso@mit.edu, darrick.wong@oracle.com Cc: linux-ext4@vger.kernel.org Date: Fri, 23 Mar 2018 18:58:01 -0700 Message-ID: <152185668144.10571.4093176467557555312.stgit@magnolia> In-Reply-To: <152185665629.10571.4584627052866250686.stgit@magnolia> References: <152185665629.10571.4584627052866250686.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8841 signatures=668695 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=9 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803240010 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Darrick J. Wong Enable the gcc/clang thread data corruption sanitizer if the builder requests it and it's available. Signed-off-by: Darrick J. Wong --- MCONFIG.in | 4 ++-- configure | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 31 +++++++++++++++++++++++++++++++ debian/rules | 2 +- 4 files changed, 90 insertions(+), 3 deletions(-) diff --git a/MCONFIG.in b/MCONFIG.in index 1344511..c3b3740 100644 --- a/MCONFIG.in +++ b/MCONFIG.in @@ -81,8 +81,8 @@ SYSTEMD_SYSTEM_UNIT_DIR = @systemd_system_unit_dir@ @ifNotGNUmake@ CHECK_CMD=true @ifNotGNUmake@ CPPCHECK_CMD=true -SANITIZER_CFLAGS = @lto_cflags@ @ubsan_cflags@ @addrsan_cflags@ -SANITIZER_LDFLAGS = @lto_ldflags@ @ubsan_ldflags@ @addrsan_ldflags@ +SANITIZER_CFLAGS = @lto_cflags@ @ubsan_cflags@ @addrsan_cflags@ @threadsan_cflags@ +SANITIZER_LDFLAGS = @lto_ldflags@ @ubsan_ldflags@ @addrsan_ldflags@ @threadsan_ldflags@ CC = @CC@ BUILD_CC = @BUILD_CC@ diff --git a/configure b/configure index 31fe8ca..c278ddb 100755 --- a/configure +++ b/configure @@ -653,6 +653,9 @@ E2SCRUB_CMT UNIX_CMT CYGWIN_CMT LINUX_CMT +threadsan_ldflags +threadsan_cflags +have_threadsan addrsan_ldflags addrsan_cflags have_addrsan @@ -917,6 +920,7 @@ enable_fuse2fs enable_lto enable_ubsan enable_addrsan +enable_threadsan with_multiarch with_udev_rules_dir with_crond_dir @@ -1598,6 +1602,7 @@ Optional Features: --enable-lto enable link time optimization --enable-ubsan enable undefined behavior sanitizer --enable-addrsan enable address sanitizer + --enable-threadsan enable thread sanitizer Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -13969,6 +13974,57 @@ fi if test "$enable_addrsan" = "yes" && test "$have_addrsan" != "yes"; then as_fn_error $? "ADDRSAN not supported by compiler." "$LINENO" 5 fi +# Check whether --enable-threadsan was given. +if test "${enable_threadsan+set}" = set; then : + enableval=$enable_threadsan; +else + enable_threadsan=no +fi + +if test "$enable_threadsan" = "yes" || test "$enable_threadsan" = "probe"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if C compiler supports THREADSAN" >&5 +$as_echo_n "checking if C compiler supports THREADSAN... " >&6; } + OLD_CFLAGS="$CFLAGS" + OLD_LDFLAGS="$LDFLAGS" + THREADSAN_FLAGS="-fsanitize=thread" + CFLAGS="$CFLAGS $THREADSAN_FLAGS" + LDFLAGS="$LDFLAGS $THREADSAN_FLAGS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + threadsan_cflags=$THREADSAN_FLAGS + threadsan_ldflags=$THREADSAN_FLAGS + have_threadsan=yes +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS="${OLD_CFLAGS}" + LDFLAGS="${OLD_LDFLAGS}" + + + +fi +if test "$enable_threadsan" = "yes" && test "$have_threadsan" != "yes"; then + as_fn_error $? "THREADSAN not supported by compiler." "$LINENO" 5 +fi +if test "$have_threadsan" = "yes" && test "$have_addrsan" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: ADDRSAN and THREADSAN are not known to work together." >&5 +$as_echo "$as_me: WARNING: ADDRSAN and THREADSAN are not known to work together." >&2;} +fi LINUX_CMT="#" CYGWIN_CMT="#" UNIX_CMT= diff --git a/configure.ac b/configure.ac index e02bdea..1cc7420 100644 --- a/configure.ac +++ b/configure.ac @@ -1385,6 +1385,37 @@ if test "$enable_addrsan" = "yes" && test "$have_addrsan" != "yes"; then AC_MSG_ERROR([ADDRSAN not supported by compiler.]) fi dnl +dnl Enable THREADSAN for all packages +dnl +AC_ARG_ENABLE([threadsan], +[ --enable-threadsan enable thread sanitizer],, +enable_threadsan=no) +if test "$enable_threadsan" = "yes" || test "$enable_threadsan" = "probe"; then + AC_MSG_CHECKING([if C compiler supports THREADSAN]) + OLD_CFLAGS="$CFLAGS" + OLD_LDFLAGS="$LDFLAGS" + THREADSAN_FLAGS="-fsanitize=thread" + CFLAGS="$CFLAGS $THREADSAN_FLAGS" + LDFLAGS="$LDFLAGS $THREADSAN_FLAGS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([])], + [AC_MSG_RESULT([yes])] + [threadsan_cflags=$THREADSAN_FLAGS] + [threadsan_ldflags=$THREADSAN_FLAGS] + [have_threadsan=yes], + [AC_MSG_RESULT([no])]) + CFLAGS="${OLD_CFLAGS}" + LDFLAGS="${OLD_LDFLAGS}" + AC_SUBST(have_threadsan) + AC_SUBST(threadsan_cflags) + AC_SUBST(threadsan_ldflags) +fi +if test "$enable_threadsan" = "yes" && test "$have_threadsan" != "yes"; then + AC_MSG_ERROR([THREADSAN not supported by compiler.]) +fi +if test "$have_threadsan" = "yes" && test "$have_addrsan" = "yes"; then + AC_MSG_WARN([ADDRSAN and THREADSAN are not known to work together.]) +fi +dnl dnl OS-specific uncomment control dnl LINUX_CMT="#" diff --git a/debian/rules b/debian/rules index f4135e8..6f694dd 100755 --- a/debian/rules +++ b/debian/rules @@ -165,7 +165,7 @@ endif BACKTRACE_CONF_FLAGS ?= $(shell if ${debdir}/scripts/test-backtrace ; then echo --disable-backtrace ; fi) COMMON_CONF_FLAGS = --enable-lto --disable-ubsan --disable-addrsan \ - --disable-e2initrd-helper \ + --disable-threadsan --disable-e2initrd-helper \ --infodir=/usr/share/info --enable-symlink-install \ --with-multiarch=$(DEB_HOST_MULTIARCH) \ $(BACKTRACE_CONF_FLAGS) $(UTIL_CONF_FLAGS)