From patchwork Wed Aug 28 23:27:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13782163 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 385AEC7114C for ; Wed, 28 Aug 2024 23:28:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDF3F6B008C; Wed, 28 Aug 2024 19:28:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C8F706B0092; Wed, 28 Aug 2024 19:28:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B57556B0093; Wed, 28 Aug 2024 19:28:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 98B3B6B008C for ; Wed, 28 Aug 2024 19:28:47 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 37F0D1A0891 for ; Wed, 28 Aug 2024 23:28:47 +0000 (UTC) X-FDA: 82503246294.20.D495F54 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf26.hostedemail.com (Postfix) with ESMTP id B0935140004 for ; Wed, 28 Aug 2024 23:28:43 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Gw16Eci9; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf26.hostedemail.com: domain of broonie@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724887659; a=rsa-sha256; cv=none; b=hbQv61YT32i48o+jap+Os+c4WO16CO6oS7tYJZ/miF5U3Q/dDfrVPNOagqOaxK3EWbKsla ggUIgiidW2gtUJdIgPhbxNv0uUeTi8NUjHfnYoVqwGrpHmfHpl6vdaYQkE1YzTowhf8+y8 NaWGfNy+L4+762a05tJVa07NUEo4Xfo= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Gw16Eci9; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf26.hostedemail.com: domain of broonie@kernel.org designates 145.40.73.55 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=1724887659; 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=6yOwcXdXWVvJlvycs735HWhRRhKvuAw/XrrKRUAoVvw=; b=3sVqIHR8fKKhKiTB1EHWLQAqKfPdynYhVyObbMhy+T3MoCi+Sdqz0WWFD4bIWTMz080XR9 VCn1Vy0d+enYFV2fStDmh6p1Ww3G3/1/I+aVhvsV0KW1IJcRa6O2fIFh8YKi6ugCvQPi5U vp2zrlOU266GrT227vBmwvlzd5SbpYA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B6C96CE19B2; Wed, 28 Aug 2024 23:28:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 068C2C4CEC6; Wed, 28 Aug 2024 23:28:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724887719; bh=rFBO85foTdFO3Yh8vyJHtUZjp9uE/dcEpKRiB9tMlcU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Gw16Eci9InmTxeQ/v1QW7kxYKwophg4FALCY/PpN4dJ76jY+jkkPcLa/dolPFzQun VJDTzYf5e5BhG4tmy7HttDryPNy1TQnLRtjJLvUYuQhf0ISni7s9KXf7j0aGTvgb7g dDf5wKBsWjvEncVR8jEJYw+DeW6adMLd4Hy5/WGZZUYTs+SFUMCSGwQk5ZCt+Zm4FI VepVGfYGX86W6Ch+pXH1fFFOHG6rqC2Wc57mpFukSmqGXwAAyzdVPgZbDM8vliymaR dPgTK9+lIPRstG8HVSiTYtDcdMpjlO6sFeKuLl0niQQGcP5/hMimcRIb7fBAN3tCjz RaDEK+jjwNZFg== From: Mark Brown Date: Thu, 29 Aug 2024 00:27:17 +0100 Subject: [PATCH v12 01/39] mm: Introduce ARCH_HAS_USER_SHADOW_STACK MIME-Version: 1.0 Message-Id: <20240829-arm64-gcs-v12-1-42fec947436a@kernel.org> References: <20240829-arm64-gcs-v12-0-42fec947436a@kernel.org> In-Reply-To: <20240829-arm64-gcs-v12-0-42fec947436a@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 , Shuah Khan , "Rick P. Edgecombe" , Deepak Gupta , Ard Biesheuvel , Szabolcs Nagy , Kees Cook Cc: "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Florian Weimer , Christian Brauner , Thiago Jung Bauermann , Ross Burton , Yury Khrustalev , Wilco Dijkstra , 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 , David Hildenbrand , "Mike Rapoport (IBM)" , Kees Cook , Shuah Khan X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2759; i=broonie@kernel.org; h=from:subject:message-id; bh=rFBO85foTdFO3Yh8vyJHtUZjp9uE/dcEpKRiB9tMlcU=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBmz7J5rOeiVZD0x1hdWNMwUC4132egoBxx8QjkFmK5 Pv24bDmJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZs+yeQAKCRAk1otyXVSH0EmcB/ 4pkgEaT4pdaEuaaASONlHltej/0jAvGExqIf5J2OhugKd+NHHJ0jsvzrA6g2c0QV0rfR2cuvQ2ljk1 RneeaD/6oRc2906gCLFz6qxPdc/szByaOGpmkFWAGOXusNxL4NMnfWG0N+hig4uXIfD/c9l2uaeXhq mfnW7i8Yqh/kkl2wism7g/xMtO4gUXlW5pO0na3MebQeWcZo41gsk2cJAZxBJqVMMa2gkQIkqCK6P9 9wSeJTrUogqeEkopqqK8cXNJ7AUmy4ENF9YK2/VNlb5hLQgmQkJ08ujQat/pcqbq8+eYPEbOjxptOx i1rHnmVb55SzZIQwmmp3Q4k24enVQl X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Queue-Id: B0935140004 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 6gdep3xgesxropupntbhfof9jc3dpxub X-HE-Tag: 1724887723-7988 X-HE-Meta: U2FsdGVkX1+ufEwCLUNoXlrGAB9E4LjmRe5xYnm/Xops0zYHKCAKWZ81AHuhmklqp8PQLMcFu02mfGOfQdqnI5o0aT/xwEB8Rkm6nXlFwSxfbvQQ5gcl0ZKLsmbe/sAZCjwkTrKjxqVwyxBBQ+F1vT15bdpLG+1mZUHGTzZnjaMzwu+XBg9r2ELQD3lZKQCHnC/4aqbg3pSbh1yv6apnjJ6AI2QdQyJ1pbg9gKsBNplhxjs+rgklAlGGhjmStnfLbfCPMtCNbq78LMHx15oymtk98YP5uswiO4Cz/IKE9VDAc1dBG6ZOZIR+YsbPhumvJRgJkRa2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Br+rHtCaGpeD9T4LQ3ukskYCNNoVade2Pl83VHmkE2XpullXAEPRtXFnQEUFFiSz99R1vWRQIHT/BKCWoSfnkjaLfFGT3H10Ttvx0eZzl+VehYHcXV5olp4W943/KfcBhcZPE5u7G5tut6S0RieykwQIp6TedO96s8o7XhZJrwn6watVF4sJ39S23Epgt7yJYfB3GpNXxvbtZsmY7VhMfXQGxi/915WkvAvqihX0DXQoipFFwgT5Jmqpxt42fluxdYrdb32XzzvFmRUg== 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: Since multiple architectures have support for shadow stacks and we need to select support for this feature in several places in the generic code provide a generic config option that the architectures can select. Suggested-by: David Hildenbrand Acked-by: David Hildenbrand Reviewed-by: Deepak Gupta Reviewed-by: Rick Edgecombe Reviewed-by: Mike Rapoport (IBM) Reviewed-by: Catalin Marinas Reviewed-by: Kees Cook Tested-by: Kees Cook Acked-by: Shuah Khan Reviewed-by: Thiago Jung Bauermann Signed-off-by: Mark Brown --- arch/x86/Kconfig | 1 + fs/proc/task_mmu.c | 2 +- include/linux/mm.h | 2 +- mm/Kconfig | 6 ++++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 007bab9f2a0e..320e1f411163 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1957,6 +1957,7 @@ config X86_USER_SHADOW_STACK depends on AS_WRUSS depends on X86_64 select ARCH_USES_HIGH_VMA_FLAGS + select ARCH_HAS_USER_SHADOW_STACK select X86_CET help Shadow stack protection is a hardware feature that detects function diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 5f171ad7b436..0ea49725f524 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -984,7 +984,7 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) #ifdef CONFIG_HAVE_ARCH_USERFAULTFD_MINOR [ilog2(VM_UFFD_MINOR)] = "ui", #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_MINOR */ -#ifdef CONFIG_X86_USER_SHADOW_STACK +#ifdef CONFIG_ARCH_HAS_USER_SHADOW_STACK [ilog2(VM_SHADOW_STACK)] = "ss", #endif #ifdef CONFIG_64BIT diff --git a/include/linux/mm.h b/include/linux/mm.h index c4b238a20b76..3357625c1db3 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -342,7 +342,7 @@ extern unsigned int kobjsize(const void *objp); #endif #endif /* CONFIG_ARCH_HAS_PKEYS */ -#ifdef CONFIG_X86_USER_SHADOW_STACK +#ifdef CONFIG_ARCH_HAS_USER_SHADOW_STACK /* * VM_SHADOW_STACK should not be set with VM_SHARED because of lack of * support core mm. diff --git a/mm/Kconfig b/mm/Kconfig index b72e7d040f78..3167be663bca 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1263,6 +1263,12 @@ config IOMMU_MM_DATA config EXECMEM bool +config ARCH_HAS_USER_SHADOW_STACK + bool + help + The architecture has hardware support for userspace shadow call + stacks (eg, x86 CET, arm64 GCS or RISC-V Zicfiss). + source "mm/damon/Kconfig" endmenu