From nobody Mon Feb 9 07:23:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1588189974; cv=none; d=zohomail.com; s=zohoarc; b=egGNlqAxMcRDS/Rwyj4kHXRQTGl0c/s2OijFF6GQGKxGO0VifEdSAkHW7KMihX/9J5NLgjFAlIk/4JMph2XYm1Klf8qmgJt+PG00Q1o1hvvEZsaa+qRxHrU1tlopbnUl9ZMNvlRWUqRyu7XGBl1Ooppc+mzotD3/P37qbkXATYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588189974; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=44CYUh9UhQiZUmAYBw706R+7pRtjUsbptNOetH+EqC4=; b=GG1hwS91a3wJE4S+y5fWfsQ4fHaCT8j6FOSYj96jkOGQhvUkA2z9E0v3gkbN0ErgDNoF8i3jQY4CgzpJm4tDecd3DgNajNwXcTU4xn+qAV+OUPJ/G9zVZr9RIqWOliR3yWQ++uHcgEIbnVZAuxa6CP8qofPeTavwqM73bVVqnk0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588189974574495.3377417393907; Wed, 29 Apr 2020 12:52:54 -0700 (PDT) Received: from localhost ([::1]:35802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTslJ-0005I8-6h for importer@patchew.org; Wed, 29 Apr 2020 15:52:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48156) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTsfr-0006on-5g for qemu-devel@nongnu.org; Wed, 29 Apr 2020 15:47:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTsdf-0000ly-Tk for qemu-devel@nongnu.org; Wed, 29 Apr 2020 15:47:14 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:18084) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jTsdf-0000lr-Ct for qemu-devel@nongnu.org; Wed, 29 Apr 2020 15:44:59 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03TJaL9M012560 for ; Wed, 29 Apr 2020 15:44:58 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 30mguxgafr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 29 Apr 2020 15:44:58 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 03TJaMfP012570 for ; Wed, 29 Apr 2020 15:44:57 -0400 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 30mguxgaf4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2020 15:44:57 -0400 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 03TJi47G008588; Wed, 29 Apr 2020 19:44:56 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma04wdc.us.ibm.com with ESMTP id 30mcu77ctg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2020 19:44:56 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 03TJitp627591030 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Apr 2020 19:44:55 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6CC496A04F; Wed, 29 Apr 2020 19:44:55 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AA7C16A051; Wed, 29 Apr 2020 19:44:54 +0000 (GMT) Received: from Buonos-Thinkpad-X1.ibm.com (unknown [9.160.84.167]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 29 Apr 2020 19:44:54 +0000 (GMT) From: Daniele Buono To: qemu-devel@nongnu.org Subject: [PATCH 3/4] configure: add flag to enable SafeStack Date: Wed, 29 Apr 2020 15:44:19 -0400 Message-Id: <20200429194420.21147-4-dbuono@linux.vnet.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200429194420.21147-1-dbuono@linux.vnet.ibm.com> References: <20200429194420.21147-1-dbuono@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-29_10:2020-04-29, 2020-04-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=516 mlxscore=0 suspectscore=1 bulkscore=0 adultscore=0 impostorscore=0 phishscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004290145 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=148.163.156.1; envelope-from=dbuono@linux.vnet.ibm.com; helo=mx0a-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 15:44:54 X-ACL-Warn: Detected OS = Linux 3.x [generic] X-Received-From: 148.163.156.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Paolo Bonzini , Tobin Feldman-Fitzthum , Daniele Buono , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This patch adds a flag to enable the SafeStack instrumentation provided by LLVM. The checks make sure that the compiler supports the flags, and that we are using the proper coroutine implementation (coroutine-ucontext). While SafeStack is supported only on Linux, NetBSD, FreeBSD and macOS, we are not checking for the O.S. since this is already done by LLVM. Signed-off-by: Daniele Buono --- configure | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/configure b/configure index 23b5e93752..f37e4ae0bd 100755 --- a/configure +++ b/configure @@ -302,6 +302,7 @@ audio_win_int=3D"" libs_qga=3D"" debug_info=3D"yes" stack_protector=3D"" +safe_stack=3D"no" use_containers=3D"yes" gdb_bin=3D$(command -v "gdb") =20 @@ -1275,6 +1276,8 @@ for opt do ;; --disable-stack-protector) stack_protector=3D"no" ;; + --enable-safe-stack) safe_stack=3D"yes" + ;; --disable-curses) curses=3D"no" ;; --enable-curses) curses=3D"yes" @@ -1774,6 +1777,8 @@ Advanced options (experts only): --with-coroutine=3DBACKEND coroutine backend. Supported options: ucontext, sigaltstack, windows --enable-gcov enable test coverage analysis with gcov + --enable-safe-stack enable the SafeStack stack protection. Depends = on + clang/llvm >=3D 3.7 and coroutine backend ucont= ext. --gcov=3DGCOV use specified gcov [$gcov_tool] --disable-blobs disable installing provided firmware blobs --with-vss-sdk=3DSDK-path enable Windows VSS support in QEMU Guest Agent @@ -5501,6 +5506,29 @@ if test "$debug_stack_usage" =3D "yes"; then fi fi =20 +################################################## +# Check if SafeStack is enabled and supported + +if test "$safe_stack" =3D "yes"; then + cat > $TMPC << EOF +int main(int argc, char *argv[]) +{ + return 0; +} +EOF + flag=3D"-fsanitize=3Dsafe-stack" + # Check that safe-stack is supported. + if compile_prog "-Werror $flag" ""; then + # Flag needed both at compilation and at linking + QEMU_CFLAGS=3D"$QEMU_CFLAGS $flag" + QEMU_LDFLAGS=3D"$QEMU_LDFLAGS $flag" + else + error_exit "SafeStack not supported by your compiler" + fi + if test "$coroutine" !=3D "ucontext"; then + error_exit "SafeStack is only supported by the coroutine backend ucont= ext" + fi +fi =20 ########################################## # check if we have open_by_handle_at @@ -6595,6 +6623,7 @@ echo "sparse enabled $sparse" echo "strip binaries $strip_opt" echo "profiler $profiler" echo "static build $static" +echo "safe stack $safe_stack" if test "$darwin" =3D "yes" ; then echo "Cocoa support $cocoa" fi --=20 2.26.2