From patchwork Wed Nov 22 09:42:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13464406 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A740C61D9C for ; Wed, 22 Nov 2023 09:44:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 049706B05A2; Wed, 22 Nov 2023 04:44:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F3B876B05A3; Wed, 22 Nov 2023 04:44:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDC736B05A4; Wed, 22 Nov 2023 04:44:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id CAC056B05A2 for ; Wed, 22 Nov 2023 04:44:25 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A52EBA03B8 for ; Wed, 22 Nov 2023 09:44:25 +0000 (UTC) X-FDA: 81485104890.11.B710344 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id D40841A0018 for ; Wed, 22 Nov 2023 09:44:23 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DhF0C8ob; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700646263; h=from:from:sender: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:dkim-signature; bh=ibX+h2ew3ywDs3y5/V0WozUSvEovuEkFpmJ1Sw1wP7g=; b=akaPi+hFo23vl2CrXcN1c7R1cmhJS3dc/LOzIGiMOCmhVg2FC2a9VOyA9/afUbdRMyalWo ZUjSZ3S15CnIpqHK5492dhFTem7lacSxkPuvFZthi76YhH0o016vIwDOPXI/q6MpIp8Pfn I2IZT+Miwgy/bMseq2otnYvJI5dkwio= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DhF0C8ob; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700646263; a=rsa-sha256; cv=none; b=cBCke74IVSLpnsRSTmnn3zUGJ1e4bHQlopWCW2S04poleJj7aAoUTwPCuoECd5MlSL7yqM X37AZX/gRQN/NzB7NjWnSFIhrWzqlqeKDZyjdV5yV6Rr+LOxMTMIrLYaNzXFpgk1xbESUo gtMpWC9SKd737kBMOJnt8EvX+8xpIXg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0CC0161CCC; Wed, 22 Nov 2023 09:44:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 041B7C43397; Wed, 22 Nov 2023 09:44:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700646262; bh=Df+HY0dV5R5n1ih4MqR1JvyrE5qdgwZR/dZq7PG88vE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=DhF0C8obSjt9Nfr4iuhMF+MfrBzvOMHkq9LmVgyYKZnO9fIVLqs7HPAS+n3JPEKJ0 dLQEv4IqHz985M/9vF5RA3TEblITjIIzbNMwRKx3W4AeIrzRpwLIpvKWycDupEWd4k HDnsgVbJ2E80hUb0HTiGD+TfDklzJH8Ma+jZ6ZDSObz510LSGSdIjpW/3G98VBnzUv DxrYCGKBYiovBFq7e5dPgwWVI3DxTMzU2LE/Db2CvFUUPnnfx59dYtoZlztgKFgZdC Xnv3q15QP1P/yyGxaz73jzcQ0IOLjraOoSEdX2zUMo2fgiDmta5EVVRM0eoUCmP1lx wbCpNkVqokZ9Q== From: Mark Brown Date: Wed, 22 Nov 2023 09:42:22 +0000 Subject: [PATCH v7 12/39] mm: Define VM_SHADOW_STACK for arm64 when we support GCS MIME-Version: 1.0 Message-Id: <20231122-arm64-gcs-v7-12-201c483bd775@kernel.org> References: <20231122-arm64-gcs-v7-0-201c483bd775@kernel.org> In-Reply-To: <20231122-arm64-gcs-v7-0-201c483bd775@kernel.org> To: Catalin Marinas , Will Deacon , Jonathan Corbet , Andrew Morton , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Arnd Bergmann , Oleg Nesterov , Eric Biederman , Kees Cook , Shuah Khan , "Rick P. Edgecombe" , Deepak Gupta , Ard Biesheuvel , Szabolcs Nagy Cc: "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Florian Weimer , Christian Brauner , Thiago Jung Bauermann , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Brown X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=2038; i=broonie@kernel.org; h=from:subject:message-id; bh=Df+HY0dV5R5n1ih4MqR1JvyrE5qdgwZR/dZq7PG88vE=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlXcz/qzN33RRp1sMMsdDeIWGemytfZkpPWLo4a cwQK9wJLbWJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZV3M/wAKCRAk1otyXVSH 0CJlB/42DNRC926QZda7ZgVHwYfL0gTMCpMI6gcouqu0xgA1HTtwNrwD613VnSOoyxtfTGVzCMY tsVAy8UOqNqRN6Dz4Zh0A+WmkLl1I5GdvGmF54We0wD2eSV5cLIVOIbdhyzcHObAzfkNwcd8LZV xX6x0wVfcf5dhIKnwCSx7NL3qmoP/2RuVklEW90UpGYkcYj/L3FIb/kydQwjinq8/NYa8ybu2FI iPgL35MV+Ppu4QMvQxgI4+09gl+0XIjyeFDoigRWiF/oIFAz8r4t9jdHMwTU+YpNFLdNthAWQ/S faocMmU8q7Y6bz+9r3UGqczI7+EUjPo4aNc0Gwlh0vqeaAX/ X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Queue-Id: D40841A0018 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: o8qh16hy19twtofwm6g4nm6copycf6xh X-HE-Tag: 1700646263-179690 X-HE-Meta: U2FsdGVkX1/yfBmJpgQHOUm35DfugdmJ19FeJ8BviT2aqNXa/ZL+zWV0sgULytTzBul4M5j/O6HOLGBwO2Ixnp8akVFPWERqTsVEz8DQmjlr+eiaYWoHqMSLD5RxnzeY9IPCT8V1Kf9qFbQLkE7OyDHInFStSLcMUIn0eZeYjP4VTOPuucJL4FJil/mlsuRa0qmUcKapMc3vio/ZPmgQGjO/wGcTuBxYOM4vr9gKEQIQDrlw6ObKGSklNgoX9D0AWvuNppDNm+bgiy1Ap/z8DbakxcrNmA2aGrx18q0M658n3jws3x6TeuZaEqUUhmEIB6PJ3k5v+50kezAzDTwa70iZtRmfTDRod78LXvJgEmK3ts9IwGp91wp6rXHx5OexYUAqoG+Wu18+rod/yF5RoOMpTEdZ8phhVXJ9AYH4mA5bWgjl+pYPBKUG192PQtZMDtNeERUPTYrs6M88/6WtI+W6GwGsO/AFyoRwDFMQMu/K25BRcNuZD5DtL2NDvGF6GE9Bgg1Qas8GWZnm5wYpfdtzQHgLojouA9thGvYnHoYbjYL+gx3YrHQuugD4RjEVdolE5c+eKiQanV02WbkzVkiT6yKWfyF1LjS2LiJD+BfyHRWtQqZvlKtfkFJ5lBbpq1K+gf+jaVIhNaGuO/9p4q+coh3sjh+HypyNBTgh5HHajEUbib26DxvjDnrI/vZSoZ3oYyOaUYEbke8R4tNYOzsWI8LpEG0tMz+zEWSjFc6I2z5OIo9hlT/2N4nMP7MFdtMoVQUCtXvSjlifqIoUIatsbcg/Q1WEC4IyahT6wVaYVNvrEofMA7GNsQAf+7A7bLfsPVZgcfxt+IsO/cy60IsoEJYXLJ3mTAblk8VOUv0ZThdpnJ+KnhkciTVZLqpNBMDv+OCQtJseRmbzZlDELcxN3r5EBJd7QEkIcXGT5OQbwIMpPrwOFL5+HSoWPKi6hA0l4ZNGv+sPR0KKyaS HdkGlDS4 oGjEfThMlaJIplXUmx2H8MF8Oa3EQxqlKvEK9p78ximKzjgqgV9CWTRHiEkB92QZDXtxj+A95bAu4wAq4LjDrrxGEfXB607jne1q5yoj+dJrUgevd+cNXJ/uQMgJvuPRf1FZ211qcN7MmhyEGu8/XxnnuvO4MzpBR9z/dlN8pqqbSA3E+wJ9rEO3ljzAHnqI0Jiotqpj67+nVnb31ror8nb4fKT/im81UfJEDqG4xwQaXNT5Z9VgCsRqTAVVZlTFKtPk7bA53jytWvDKlcjGYns+0oNgswo3yPSd6t8Pa5Fe+ZmDqkxvBDio01a4Em2PMrSdnVEGkLjN0yZwlHE/TwUY5L/lbGwgIT4poNVmYqC0rSWsIvXjUvUyZqQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Use VM_HIGH_ARCH_5 for guarded control stack pages. Signed-off-by: Mark Brown --- Documentation/filesystems/proc.rst | 2 +- fs/proc/task_mmu.c | 3 +++ include/linux/mm.h | 12 +++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 49ef12df631b..1dfc5cb20f28 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -570,7 +570,7 @@ encoded manner. The codes are the following: mt arm64 MTE allocation tags are enabled um userfaultfd missing tracking uw userfaultfd wr-protect tracking - ss shadow stack page + ss shadow/guarded control stack page == ======================================= Note that there is no guarantee that every flag and associated mnemonic will diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index f0a904aeee8e..29fd7d6fbeb0 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -701,6 +701,9 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_MINOR */ #ifdef CONFIG_ARCH_HAS_USER_SHADOW_STACK [ilog2(VM_SHADOW_STACK)] = "ss", +#endif +#ifdef CONFIG_ARM64_GCS + [ilog2(VM_SHADOW_STACK)] = "ss", #endif }; size_t i; diff --git a/include/linux/mm.h b/include/linux/mm.h index 8b28483b4afa..3c96fc6c1128 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -352,7 +352,17 @@ extern unsigned int kobjsize(const void *objp); * for more details on the guard size. */ # define VM_SHADOW_STACK VM_HIGH_ARCH_5 -#else +#endif + +#if defined(CONFIG_ARM64_GCS) +/* + * arm64's Guarded Control Stack implements similar functionality and + * has similar constraints to shadow stacks. + */ +# define VM_SHADOW_STACK VM_HIGH_ARCH_5 +#endif + +#ifndef VM_SHADOW_STACK # define VM_SHADOW_STACK VM_NONE #endif