From patchwork Thu Nov 7 21:39:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 2008169 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2023-11-20 header.b=I7WM/NE+; dkim=pass (1024-bit key; unprotected) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-oracle-onmicrosoft-com header.b=b0+nVMKG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XkwWQ1tKFz1xxq for ; Fri, 8 Nov 2024 08:41:38 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 509BF3858CDA for ; Thu, 7 Nov 2024 21:41:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 64E9A3858CDA for ; Thu, 7 Nov 2024 21:40:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 64E9A3858CDA Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 64E9A3858CDA Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1731015605; cv=pass; b=toze2KzSMAYd7B1S6z4hlidy8OZ5swp6KEW5CmlWCuRJ4c4fQcCYfOBqan8GyPYbno/LYrNyhunrcNzvk1veBjytGHSPGV0GkvgeDtUnOhZ+0AueYyadJ4JtluI5wdzXSwAau9oN0n79sm4uwi9PZukYnzzCv6fWgJ4bY9HINiI= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1731015605; c=relaxed/simple; bh=Porhq0sRFbhd50ohjoGZSg5Yc0OZR8Zj5DOaDIQ678s=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=n5pWqKCVVWhSr/qFJoEaLymfsqfP12NFWXoCAPz3WcBeltCaTFbhYfFR8Uo1LnifjhzU3YoPezgw1baJx5e5FcImP5Z/9IG/kw3Id2eOE6WB4X8puOs92XTSjlUGM3XGOmtSRdh9rjMlJ/qgi/UV7RlA/MN1ytyW7CRPX1yWSc0= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4A7KfevI003315; Thu, 7 Nov 2024 21:39:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=AvDun6JbAUKZdFugGq3lyPh28WK0kUHLHjQqoogrMmE=; b= I7WM/NE+mBHirSGkxmGJsqggJcYWiw6gV4JYpyf1E34+SMf2qts5aEp5XCP3qU9P RqJXF/EegkKwkXrgzrD4j+JlgoIG6OjFVXuUEJaYd8Vb0Cjvsh/o8gX9plqyi8TC UkgnO1OEaZB0GfJJxneQEIu6LD0omDOhGycFQITeJ3BgKLIuef053meqjWYv3TXF 6vSLCA6K1II23Qr/pf57RjGrWJIL2tHUHIBhFKYVhhoVhU/2zjdV9HRvfwYL7IVY XOdru68AVW0Eyio7Ecc9+iFhFdGjIiT74WzC0DiMuU9bkr1r5+mV9hZ3vS8Qk/HX Kx+s6Sv6S5dnxTZ2+iRhaw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42ncmtbmyy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Nov 2024 21:39:57 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4A7LF4Y5008413; Thu, 7 Nov 2024 21:39:57 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2044.outbound.protection.outlook.com [104.47.58.44]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42nahamefk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Nov 2024 21:39:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xmKUcjToG0U6MmQYMCztu6TIoI4ob9FN9h9sRYnxis7iC8ufOfWeZd6d0YzGPv98IUDUJCjEliPdhcJCoZKQZVVcxubzhL2EFbErnfz4ER3GvbtRXJo5xEPC8IsryFuGu3k+0QLRCmBie8NGE6oooeEDJmbunpwjKu2ZwYxoVpy48tH7hb8pqg0O1G/r3xBQ22E263BrpOs9uZs89Z4+iUBm04017n2H8JH6eGMh9UMmiqnHBvwcBWLzQGRB5VCX2wk4hHcSClhX3cpmOSIkcelRyO7GH1rzpFx4Jvf6NHmFIxeVIlQ8X/IdlPOLk3/Z0AQf10RjMwaQ6uRHg9eGnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AvDun6JbAUKZdFugGq3lyPh28WK0kUHLHjQqoogrMmE=; b=UKdEuu+nvoxZedPwTouE3Cp/Qjth7DSZPbY/4rPRRt0hYxHYKezvvtcTmQHkKWud1AVTMTo4CH6HbjPU8nocoKy2wtZf17DINAkcYsfmfRBS+nF9BiQuJl97J9X4UfU+omak1OhxsIYkc4BJZdIq/jJYoPFZswrAyZ3MUKJEmUseoMIItM9mmmWNblLi8MqVpJCWAFeN3g5C+Yaa/J4iyIu4kgRvzW/5Wl3/6dD945hb7wfwJ3fqiU41B5j7voGRko03cB7PUmrRtKvOl8tEPzwEBRO2YSDlZTmziJRA+GR/H8f2RElEOmxVdEXrDTFay8VYDkMLSo9VY0/i0i/+lQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AvDun6JbAUKZdFugGq3lyPh28WK0kUHLHjQqoogrMmE=; b=b0+nVMKGj/sjpkqweb0PxJxBAmrBwGBML5v+Tvu/ay+BYKn3xIOztlsTknxFpqwTs60FqBTXPTHGuQ1yDtGggwsIMQ8aCZP0hJF0zkou8shsh42PoLDnNh1lzcmlE2cYyd3ykGaEpnP6yzLDr0RVKjHEtlRUnzMPCRvs8j4II2o= Received: from SA1PR10MB6365.namprd10.prod.outlook.com (2603:10b6:806:255::12) by SA1PR10MB6413.namprd10.prod.outlook.com (2603:10b6:806:258::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Thu, 7 Nov 2024 21:39:54 +0000 Received: from SA1PR10MB6365.namprd10.prod.outlook.com ([fe80::81bb:1fc4:37c7:a515]) by SA1PR10MB6365.namprd10.prod.outlook.com ([fe80::81bb:1fc4:37c7:a515%3]) with mapi id 15.20.8114.028; Thu, 7 Nov 2024 21:39:54 +0000 From: Indu Bhagat To: gcc-patches@gcc.gnu.org Cc: richard.sandiford@arm.com, richard.earnshaw@arm.com, Indu Bhagat Subject: [RFC 4/9] opts: doc: aarch64: add new memtag sanitizer Date: Thu, 7 Nov 2024 13:39:29 -0800 Message-ID: <20241107213937.362703-5-indu.bhagat@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241107213937.362703-1-indu.bhagat@oracle.com> References: <20241107213937.362703-1-indu.bhagat@oracle.com> X-ClientProxiedBy: MW4PR04CA0216.namprd04.prod.outlook.com (2603:10b6:303:87::11) To SA1PR10MB6365.namprd10.prod.outlook.com (2603:10b6:806:255::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB6365:EE_|SA1PR10MB6413:EE_ X-MS-Office365-Filtering-Correlation-Id: 496518bd-6d72-4c02-e6ce-08dcff74b751 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|10070799003|366016; X-Microsoft-Antispam-Message-Info: NvTvju77IULrokOB5EoYhUmg/zvv9alNDgVslSdVHMMUe55WxRZ8jApFAZZG7Z/vrugSxRK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1PBeI2xMpfJkmf9s6dlEH4waAnuvObb2F6PwSBsmGVL8m/QJmQANAz2zW46jRCFfS6vC9rg/5GAx0m5h2dyv88gMpyQG4ISrGQcnN4fvAZ2WYI0LX5f2e4Ljxy77753e6Akzor7/H+PaxvC4Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA1PR10MB6365.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(10070799003)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: d3DBWJ7k41zb3A69DZcvAD/nbeq/1/V6xbn0NcgG7jz8BtD9F144Bdsq88ZEP9QLdhbCicOlDVJvIGjiN9JZnEckw62HoRBnGOy0rBig+zZCurHE+1dSo3JQWvjBflbgmIpCKV8CenjsxCHiq0kgkR0cNLbHIKhnJJVyVjWKia5E+VYsHC6djAbcfpC+/v22Q9lSHxtYKmCkmUsIY7lX6zaXzBojUdLi5v2vIFCxRKp9S30kS45y17bBDAmaqcng/4K+VP98k9HnltlHnJKXnFd9xrX+jncAIkiozYDetHfFqxH5Tz4J9P8jq0vRxqRZdIPBUzQo4+n9oCxMlUKfWfm7589kJBjMZu1bi4oh8AD0z6ZWSUxnDxcBspBHWxAx6QWvX6L9kiCIGMO9TuBD4ofsXEX9Sx4nASVKoMFB8tTxhzWsamygdmnD17usMAKmU+ua8JYJXWizSZ6JTo9t7iFfxLGkSUGJZ7ADf+sMt8uX/lgDcohDuhARc65VrTfb7LIfXYExm2oR1pvMz6e9g6wnr+Nelj2YfrjxVX2xvlDwY3FHAMGb/dAZWswi0oBsPNLQiupSLIh4Kt8tEkGQ9eA3wnF1FkpO2/n02gsRwaAvuF8OiIPXCnEop5vx/GgurqCVcTKfGKmGmflmyK1YfH0Bc2LqUH8WQPhCzEy0jwjNv1zSfuOJLxP6xrdXxC9zpJcdV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aC3+xW3MMQpdSPIywEFN7TypS9aifVNiRPPCQPzpKOMuDYlb34r0yOHsksC9m5GYV0zGag6QV0BInEF/KgvyPGbsN26WGh+6w+HJcj4lgQZ3uAGS46/4eGbt79zvwl3Pfcu6bctVhqZlPueIrsnbOuJe1/76AF8y4s9GZ158oofdPYxF2vtWhCjKPAUkwAfz9L9nAKtEIxSiUglC/jBvr9RuqsdMJgTPXHMBc32Znln80wloSICmiQxUDIvha/kRQs3RW013qH5eW6N1Xp110QRCZaPTUaDVH+Ior70xRI7fR6H9qyTA6D6DNr4DCuLht2vfO9splzZNNxQDO0bPSjsf1IYcJy0MSYkc3upJXF/OS/hEEoH/OYLg/r3ysFI95jBgjuLjNfMtnulIc32u5sOazgakgxLwLT2Ck2ZU+bb3nwuIpCoyBpFKpgp0R9nPkqXPGZn/OyqSzL6Bnd4jA1jeDmGjRii7z6x6wALNQuUfA/B++nJ3pklJpm7WQmVIVmJZPmxpi94lI8GchRAUm72UdDHeVhJk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 496518bd-6d72-4c02-e6ce-08dcff74b751 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB6365.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 21:39:54.1611 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fF8hyQcmlkY1GHR3JGEP1Wdo5ycVRr3pW6QSpzXWtbyr8scAbhzjmrCKr3cygeC+M0jgLRPr0P5I9pFk4fQ0hg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6413 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-07_10,2024-11-07_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411070170 X-Proofpoint-GUID: 3p6aR5XknlDxLToMpTu_tF5ftcyQLJUn X-Proofpoint-ORIG-GUID: 3p6aR5XknlDxLToMpTu_tF5ftcyQLJUn X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Add new command line option -fsanitize=memtag with the following new params: --param memtag-instrument-stack [0,1] (default 1) to use MTE insns for enabling dynamic checking of stack variables. --param memtag-instrument-alloca [0,1] (default 1) to use MTE insns for enabling dynamic checking of stack allocas. Add errors to convey that memtag sanitizer does not work with hwaddress and address sanitizers. Also error out if memtag ISA extension is not enabled. MEMTAG sanitizer will use the HWASAN machinery, but with a few differences: - The tags are always generated at runtime by the hardware, so -fsanitize=memtag enforces a --param hwasan-random-frame-tag=1 Add documentation in gcc/doc/invoke.texi. TBD: - Add new command line option -fsanitize-memtag-mode=str, where str can be sync, async or asymm (see https://docs.kernel.org/arch/arm64/memory-tagging-extension.html). This option will not affect code generation; the information will eventually be need to be passed to perhaps the linker. This is contingent on what ABI we define between userspace applications and the kernel for communicating that the stack be PROT_MTE. gcc/ * builtins.def: Adjust the macro to include the new SANTIZIE_MEMTAG. * flag-types.h (enum sanitize_code): Add new enumerator for ANITIZE_MEMTAG. * opts.cc (finish_options): MEMTAG conflicts with hwaddress and address sanitizers. (common_handle_option): SANITIZE_MEMTAG tags are always generated (randomly) by the hardware. * params.opt: Add new params for MEMTAG sanitizer. doc/ * invoke.texi: Update documentation. gcc/config/ * aarch64/aarch64.cc (aarch64_override_options_internal): Error out if MTE is not available. --- gcc/builtins.def | 1 + gcc/config/aarch64/aarch64.cc | 4 ++++ gcc/doc/invoke.texi | 11 +++++++++-- gcc/flag-types.h | 2 ++ gcc/opts.cc | 15 +++++++++++++++ gcc/params.opt | 8 ++++++++ 6 files changed, 39 insertions(+), 2 deletions(-) diff --git a/gcc/builtins.def b/gcc/builtins.def index 0c76ebc5e31a..659c7c2b5c13 100644 --- a/gcc/builtins.def +++ b/gcc/builtins.def @@ -245,6 +245,7 @@ along with GCC; see the file COPYING3. If not see true, true, true, ATTRS, true, \ (flag_sanitize & (SANITIZE_ADDRESS | SANITIZE_THREAD \ | SANITIZE_HWADDRESS \ + | SANITIZE_MEMTAG \ | SANITIZE_UNDEFINED \ | SANITIZE_UNDEFINED_NONDEFAULT) \ || flag_sanitize_coverage)) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index f2b53475adbe..1ef2dbcf9030 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -18518,6 +18518,10 @@ aarch64_override_options_internal (struct gcc_options *opts) && !fixed_regs[R18_REGNUM]) error ("%<-fsanitize=shadow-call-stack%> requires %<-ffixed-x18%>"); + if (flag_sanitize & SANITIZE_MEMTAG && !TARGET_MEMTAG) + error ("%<-fsanitize=memtag%> requires the ISA extension %qs", + "memtag"); + aarch64_feature_flags isa_flags = aarch64_get_isa_flags (opts); if ((isa_flags & (AARCH64_FL_SM_ON | AARCH64_FL_ZA_ON)) && !(isa_flags & AARCH64_FL_SME)) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 7146163d66d0..f8bd273b07ad 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -17626,8 +17626,9 @@ the available options are shown at startup of the instrumented program. See @url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags} for a list of supported options. The option cannot be combined with @option{-fsanitize=thread} or -@option{-fsanitize=hwaddress}. Note that the only target -@option{-fsanitize=hwaddress} is currently supported on is AArch64. +@option{-fsanitize=hwaddress} or @option{-fsanitize=memtag}. Note that the +only target @option{-fsanitize=hwaddress} and @option{-fsanitize=memtag} are +currently supported on is AArch64. To get more accurate stack traces, it is possible to use options such as @option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent @@ -17676,6 +17677,12 @@ possible by specifying the command-line options @option{--param hwasan-instrument-allocas=1} respectively. Using a random frame tag is not implemented for kernel instrumentation. +@opindex fsanitize=memtag +@item -fsanitize=memtag +Use Memory Tagging Extension instructions instead of instrumentation to allow +the detection of memory errors. This option is available only on those AArch64 +architectures that support Memory Tagging Extensions. + @opindex fsanitize=pointer-compare @item -fsanitize=pointer-compare Instrument comparison operation (<, <=, >, >=) with pointer operands. diff --git a/gcc/flag-types.h b/gcc/flag-types.h index df56337f7e84..3f4f4f13570f 100644 --- a/gcc/flag-types.h +++ b/gcc/flag-types.h @@ -330,6 +330,8 @@ enum sanitize_code { SANITIZE_KERNEL_HWADDRESS = 1UL << 30, /* Shadow Call Stack. */ SANITIZE_SHADOW_CALL_STACK = 1UL << 31, + /* Memory Tagging. */ + SANITIZE_MEMTAG = 1ULL << 32, SANITIZE_SHIFT = SANITIZE_SHIFT_BASE | SANITIZE_SHIFT_EXPONENT, SANITIZE_UNDEFINED = SANITIZE_SHIFT | SANITIZE_DIVIDE | SANITIZE_UNREACHABLE | SANITIZE_VLA | SANITIZE_NULL | SANITIZE_RETURN diff --git a/gcc/opts.cc b/gcc/opts.cc index 089e5e019db3..d0e28ce987c6 100644 --- a/gcc/opts.cc +++ b/gcc/opts.cc @@ -1290,6 +1290,13 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set, report_conflicting_sanitizer_options (opts, loc, SANITIZE_USER_ADDRESS, SANITIZE_KERNEL_ADDRESS); + /* Sanitizers using Memory-Tagging Extension conflict with HWASAN and + ASAN. */ + report_conflicting_sanitizer_options (opts, loc, SANITIZE_MEMTAG, + SANITIZE_HWADDRESS); + report_conflicting_sanitizer_options (opts, loc, SANITIZE_MEMTAG, + SANITIZE_ADDRESS); + /* Check error recovery for -fsanitize-recover option. */ for (int i = 0; sanitizer_opts[i].name != NULL; ++i) if ((opts->x_flag_sanitize_recover & sanitizer_opts[i].flag) @@ -2148,6 +2155,7 @@ const struct sanitizer_opts_s sanitizer_opts[] = SANITIZER_OPT (pointer-overflow, SANITIZE_POINTER_OVERFLOW, true, true), SANITIZER_OPT (builtin, SANITIZE_BUILTIN, true, true), SANITIZER_OPT (shadow-call-stack, SANITIZE_SHADOW_CALL_STACK, false, false), + SANITIZER_OPT (memtag, SANITIZE_MEMTAG, false, false), SANITIZER_OPT (all, ~0U, true, true), #undef SANITIZER_OPT { NULL, 0U, 0UL, false, false } @@ -2782,6 +2790,13 @@ common_handle_option (struct gcc_options *opts, SET_OPTION_IF_UNSET (opts, opts_set, param_hwasan_instrument_allocas, 0); } + /* Memtag sanitizer implies HWASAN but with tags always generated by the + hardware randomly. */ + if (opts->x_flag_sanitize & SANITIZE_MEMTAG) + { + SET_OPTION_IF_UNSET (opts, opts_set, + param_hwasan_random_frame_tag, 1); + } break; case OPT_fsanitize_recover_: diff --git a/gcc/params.opt b/gcc/params.opt index 7c572774df24..a87df398a742 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -90,6 +90,14 @@ Enable hwasan instrumentation of store operations. Common Joined UInteger Var(param_hwasan_instrument_mem_intrinsics) Init(1) IntegerRange(0, 1) Param Optimization Enable hwasan instrumentation of builtin functions. +-param=memtag-instrument-stack= +Target Joined UInteger Var(param_memtag_instrument_stack) Init(1) IntegerRange(0, 1) Param +When sanitizing using MTE instructions, add checks for all stack automatics. + +-param=memtag-instrument-allocas= +Target Joined UInteger Var(param_memtag_instrument_allocas) Init(1) IntegerRange(0, 1) Param +When sanitizing using MTE instructions, add checks for all stack allocas. + -param=avg-loop-niter= Common Joined UInteger Var(param_avg_loop_niter) Init(10) IntegerRange(1, 65536) Param Optimization Average number of iterations of a loop.