From patchwork Sat Feb 3 12:25:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13544136 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 A871FC4828D for ; Sat, 3 Feb 2024 12:30:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C3B26B0093; Sat, 3 Feb 2024 07:30:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D7AA6B0096; Sat, 3 Feb 2024 07:30:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1522F6B0098; Sat, 3 Feb 2024 07:30:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EC30A6B0093 for ; Sat, 3 Feb 2024 07:30:57 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B112D1205D7 for ; Sat, 3 Feb 2024 12:30:57 +0000 (UTC) X-FDA: 81750426954.04.E924B9A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id D00591C001C for ; Sat, 3 Feb 2024 12:30:55 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nZ+FVrta; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.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=1706963455; 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=uI8doFRdMNxyLZ96w6OPYHbxPBJXwa5V9eJEB7Z5WuQ=; b=wQaYBuiEvB3laR7HWTlkoimiDWf2SLl5ca27K4jp77zhVrgTVnzZzoUrYVv4hJWWvz1IwF ZMNiLcx1monjMAqHHp+2ETT8Msr3k4mCOYCnJWED8mfIR+YlqKld25HVgRJXMTSF3FS/jT MuLJzZKrmiO3ThSV0aoo8JGc2Tggfk8= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nZ+FVrta; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.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=1706963455; a=rsa-sha256; cv=none; b=JmTuswRAYCUprAM+eFkIeHgxhitmbqGW8YHkXEHxjXiXht6xbNUoAhbQLyTpr/E0rQtB/g ZW8ptHx0j1Lc1Ywx3XvENyTAGuG/3WqptSzynTWaINXy0SgrOdo48QK+HcCiztXF0R87Ws C4/158cIAOe0FJWGxXX/xju/3bNLTy4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 11D6460A13; Sat, 3 Feb 2024 12:30:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EBDEC433F1; Sat, 3 Feb 2024 12:30:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706963454; bh=noIMiNXXaRbZmSrB1LMm4LQSI3w8gaJJhGiAy9NbIgk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nZ+FVrtarYuPfV2QgPHzVDN1mdXXrUA/eCIkI0+jD+9lmq8AK1SrIHQkP+okJ5xIf Nrtap97nj/w0mCOq2XBkzeEft1WmagOP1qx9TFRd7EBruLsj53cPf7oLI70WJMf2MQ dMWZcj6emLEFTlJCV/Yxh7bjw5A6lQLRrkdBfnfN/U4F2NkeGs3HNfZoP1yPp8rSJL VlptsEVCXxOwPpctcB+HH0ogyB4/oAE/pVEWNyqU0lHP8t821iVQKCaDfz3W3uU9m5 AOL2G84ZrXkvUQOBBwDNufzWgILEjqVWtfYDLJgzCbrfg21DlUhhzOPjJVMkEgy4Fh 1cwCvG9ZSMVbQ== From: Mark Brown Date: Sat, 03 Feb 2024 12:25:37 +0000 Subject: [PATCH v8 11/38] mm: Define VM_SHADOW_STACK for arm64 when we support GCS MIME-Version: 1.0 Message-Id: <20240203-arm64-gcs-v8-11-c9fec77673ef@kernel.org> References: <20240203-arm64-gcs-v8-0-c9fec77673ef@kernel.org> In-Reply-To: <20240203-arm64-gcs-v8-0-c9fec77673ef@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-a684c X-Developer-Signature: v=1; a=openpgp-sha256; l=2038; i=broonie@kernel.org; h=from:subject:message-id; bh=noIMiNXXaRbZmSrB1LMm4LQSI3w8gaJJhGiAy9NbIgk=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlvjDZ2Io6GgPo7IKBDhinOWnY04tvqYzF/2M4PbR8 tBVQvoaJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZb4w2QAKCRAk1otyXVSH0FoMB/ 489Ce9yGOrMf8qmH57w0iu49g2q5ScfPLlvHIGHqIG2PImWln+Xihqvl1m9KbzdISpWJxeNsTTO2XF aJDD06/nq2t7tQverEzEP7/LK2GVlDIYoue95rUKVV2+43+ztP2j03uGGCbBzlhTZphrchLv+3O2ul +HEP0ncnuw1ybRxXFNlo3BHi/OXXeFTRf3CYFPyr+vcf1TxJd/SCdsXeogobq3zH+dHSWskU+6/doU tTsPKvaiitj/K4V2ScTqfmaf40lD8CCSQszd9G5pPMgQYd9N2FC6aVOoLa9MLanU9pHtBoiWh4Tnew iIOq6LPE9HIfe5k2+L9fZIvT/kWhuG X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Queue-Id: D00591C001C X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: xy8i31x1757ck5z5stimt7mi87equ6iu X-HE-Tag: 1706963455-897595 X-HE-Meta: U2FsdGVkX1/lI9wAlS5cJDjHPdX/i02qjukVJo6Pe+fsu9gMo/eDySvO1zUbZkHVZRg/GIgXy0vEm97OhvzG+7Is5FvQaFy/x0oRuh6IP3lNJfGuS0epmRrIhzOS4qGoXHg+MUZC8p5Y63gaIALezmBPpFekhM0kk3CM7YLeTXXJjpLpqC6ZV2BmZPimawPuIddSigPfwUWxoDbkBUnfqTXUyPV/QiPLuuesPR0tbVxTCW3QFySXw3wyaE/i3s16fltIzlDqGeufKrvaE3U73b0cTmxT7IuAYqbovO3VaoG157EVmh5O+OLKMZt9FD8QYrdoo3neybXdIDK44vY8N+jHyR//TPpTU/5Ji6lJNUm52tKtH1CB4DjnKZm8I9GhPNDmJyLZHZ45tUmlD7UlhaTm3qW4962dkizbNQ1OwNMXUYVMGNYW8IULjmnHtZgvhwl2TXyFJdkCGPSzfjbk9v3nUzqHfRiYEueelqUnHROGSCY6yiAyyXrnJa1BWrBzDFJy4TR2524xdaNLpoTTdZsgPvMHbn0NOVS6Llh9zMSamMWYdZO5O5Pa34NfwFytE+wAqrWL+IRLoT+YEcwlK1hZoDSn0246r3In8eXNzhAhZ7K25mz0K/DhBKWvUJqU1k2vSn4MldAWuEmXk9UDo9U6f+qzEkmcLV9BzFNAh6s1M1HK8xl9QMY7/yNvw+55ouSv/nEDpFm+FGpTbE0zm0UsOaGWkzlnN9CaJzObIoZ+IC/bZ+kenLOz4/WXawO8VjZOu+ldIXk41dC/v+VOIZafbg6WL/um1AOuVP2eG51SRUVwY8UpsmfXNiJh4xfGkpVz/41cN90jJKEJr5h/rI+vZCqPEaqDnqitHKe2tsC7xUr7S4bn4jGYHPmLZ5ZSWLhY/eXKNbhSMPYOl7cEAPNIge2X/wid9Bu7a4f+YOIRrPTvmgH8GBi0OIh+XRHCqMbQorSBDXcCG/kYi5T Rb8KAe+i HJcLn7qEqrGyME5s4/8eUMXKGCDc1O+fspyT4TS2JnEqR5Za9WCbAkGyjIhwiLbYTEEjIZb4f56jfFk+pnM+8sd+OtzDGn9OvIVIPPiCBp7dkjq7m2jojZmoEgxT/Mrzh1HhPLxHy4ob48cLVIWh0IcX88Phg7or78d/MvehyIWvZMvhbz2vgO2KWLH9OyXwXuEC2hanNWEzPzpRR6wkMl+idfVD28//ZePTZCg9Qr9sseptd5FQkieprfAQ+AYaLBeWYVcdyuF69AoRa+gqc0JOfQbXtLVnCSvApmecsI7ECfRko5WNGEe7RrIjrrhlqrghVbfmbzlz/Z8VATL/3nhP8ICPtsVUrMpNT/JI+kK9lZ/RkfHE9uitz5Q== 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 104c6d047d9b..0392c3b74650 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 ff2c601f7d1c..fb0633d8e309 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -702,6 +702,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 0b1139c5df60..6cc304c90c63 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