From patchwork Mon Oct 23 13:20:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13432850 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 230AFCDB474 for ; Mon, 23 Oct 2023 13:25:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231282AbjJWNZx (ORCPT ); Mon, 23 Oct 2023 09:25:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233529AbjJWNZS (ORCPT ); Mon, 23 Oct 2023 09:25:18 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D5822723; Mon, 23 Oct 2023 06:23:33 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0C2AC433CB; Mon, 23 Oct 2023 13:23:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698067412; bh=Aen7tI3tV8QliCw4GY+TVMrWQ7BjK/IzHu4XGOJDu+I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PUfhQYxG5F0WWBAvnGb5yUqpTjKpqij1bAq1dz2aGNEJTdM21ed2h+AqiTYM4ZCBp MtlbaqQgbdsQeLgLuQq1kjoALRDhtqoH5zI7zBHjKemt1ZfrhbSGovRJHa7G5yZMK/ P/s9t+UrumP48n9xlevqPHF8V57ikEOzwivvMfmxhE3HDTyTR4z/qJ9cNEApJvKf97 bshm3781uRRExdCR1Id9g2S7sFCxd1RGq679qLe/Egl37bSl6n3tubjvKoaUetIXay BaVYxt+MSMf6Hrh/HcfYZ2zf6Q6JckNeQxc1Kp1jr1WXu/DB13x+Nd32qYtFXXypvw jnFevocx0bv2w== From: Mark Brown Date: Mon, 23 Oct 2023 14:20:40 +0100 Subject: [PATCH RFC RFT 1/5] mm: Introduce ARCH_HAS_USER_SHADOW_STACK MIME-Version: 1.0 Message-Id: <20231023-clone3-shadow-stack-v1-1-d867d0b5d4d0@kernel.org> References: <20231023-clone3-shadow-stack-v1-0-d867d0b5d4d0@kernel.org> In-Reply-To: <20231023-clone3-shadow-stack-v1-0-d867d0b5d4d0@kernel.org> To: "Rick P. Edgecombe" , Deepak Gupta , Szabolcs Nagy , "H.J. Lu" , Florian Weimer , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Christian Brauner , Shuah Khan Cc: linux-kernel@vger.kernel.org, Catalin Marinas , Will Deacon , linux-kselftest@vger.kernel.org, linux-api@vger.kernel.org, Mark Brown , David Hildenbrand X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=2302; i=broonie@kernel.org; h=from:subject:message-id; bh=Aen7tI3tV8QliCw4GY+TVMrWQ7BjK/IzHu4XGOJDu+I=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlNnPDFVIE5B+3ze9Js5B/BaPIgTybaZYHGdRh4PW0 6Oj2umeJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZTZzwwAKCRAk1otyXVSH0KE8B/ 0Yhwcn5e0MrNb78oefgVk9aNyTT/WKEGRnXSgKXCdjkNFZhT2+xTmF9ITt1dweV+G4orXP7/lL+SOT FJvK8bgzC6IS4CdUypaNnYJYDL9hlfmWcFWgtiPmZnXOy1dLwT43nEuOhMBqgKgP8nw2AJMlvujjN7 DHc/b3+j/+lpbkBqsT79SEqUUS0K1eUhDlGBnyNLTJaxgwFd+M9U0WNoGjYqydgXpI68STiW6dFrUa pKEsaxwMtgm9IUGReNwDpcsR0jrQlNIlRElT07IC2RVlr3JPw4G8QRdWPtgV+h9dmQYSjVvfQxAh9k u0YSVwQb/NmgC9/VB0M6Cysl/4Hp+p X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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 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 66bfabae8814..2b72bae0d877 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1926,6 +1926,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 3dd5be96691b..4101e741663a 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -697,7 +697,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 }; diff --git a/include/linux/mm.h b/include/linux/mm.h index bf5d0b1b16f4..1728cb77540d 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -341,7 +341,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 264a2df5ecf5..aaa2c353ea67 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1258,6 +1258,12 @@ config LOCK_MM_AND_FIND_VMA bool depends on !STACK_GROWSUP +config ARCH_HAS_USER_SHADOW_STACK + bool + help + The architecture has hardware support for userspace shadow call + stacks (eg, x86 CET, arm64 GCS, RISC-V Zisslpcfi). + source "mm/damon/Kconfig" endmenu