From patchwork Mon Nov 20 23:54:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 745918 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B9A13B2B7; Mon, 20 Nov 2023 23:55:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WV41QAv1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F53DC433C7; Mon, 20 Nov 2023 23:55:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700524531; bh=FEKtInmB6mFDaJj7WRZ2UJIP9/hPzlhQkMpJUP8BQq8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WV41QAv1rJxcj+vxnp7S0mCF1VeOKiaAkuL4CwSZ6/Jeks1hLwuKK9WMXrg9P0gd1 X3qZWI8NRU/tKrfslrA+LaaeugWU79B1mu7XTuYGFZk5bsbtqgQM/0bXJcBahZwpvE jXUUSP0ha5tVnF3yjM2iPpZiU5ACkYrzE0iNw6sD4/7g0wtTq0YDNx6pGtzmwbM8iC 4vcFDLPjdmR7wDMVw7PM9zhH5taYkZLzn8kyHG8RfuJoNbEGbirETrJCW8uLokNkG7 Y+XB8yIlaco10Anz0mUFJR443r/paPgMNsRVBJ62m+Q1kbY0AFN2MG7rekzOV0mDnN jG6Ws5gd2hYaw== From: Mark Brown Date: Mon, 20 Nov 2023 23:54:29 +0000 Subject: [PATCH RFT v3 1/5] mm: Introduce ARCH_HAS_USER_SHADOW_STACK Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231120-clone3-shadow-stack-v3-1-a7b8ed3e2acc@kernel.org> References: <20231120-clone3-shadow-stack-v3-0-a7b8ed3e2acc@kernel.org> In-Reply-To: <20231120-clone3-shadow-stack-v3-0-a7b8ed3e2acc@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 , Kees Cook , jannh@google.com, bsegall@google.com, 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=2350; i=broonie@kernel.org; h=from:subject:message-id; bh=FEKtInmB6mFDaJj7WRZ2UJIP9/hPzlhQkMpJUP8BQq8=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlW/HeNGumee5BBgwYzS/jfuVxfmeNbdDo3h499Lve AEC5g2GJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZVvx3gAKCRAk1otyXVSH0MH8B/ 49OKKVqeGmJqH5SHRyriH7oXHLzEzq1hobb2QMbBMeWL3VRKyHvLSTHT7IONQZP9FOOs45Dl+Jbspj tkMdlvyxD8ciXP9uA1FlLLCsTh/Nl6K3upIWBVPL6QGN14wVx0XUfQe9saZn1BCkx48IfsFtoMY3lE VggZmBbeEUAkFRuD1Cwq655/PHcXYF7mZx10TVcyISzeZg+Xx/QbVUm9rflE/4Il3EV3+9NqKnT0oF cVRbKrLqJUp7D9F1mOQQUkkR6ppUCctRNdNpbT+m+JFgqgKenpvg4ru1ckIGBRIlr9gB9Mv3DvWfPu xydhRD0JNsM+AgQGPUlS0kJ4/f709v X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB 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 Signed-off-by: Mark Brown Reviewed-by: Mike Rapoport (IBM) --- 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 3762f41bb092..14b7703a9a2b 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1952,6 +1952,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 ef2eb12906da..f0a904aeee8e 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -699,7 +699,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 418d26608ece..10462f354614 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 89971a894b60..6713bb3b0b48 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1270,6 +1270,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 or RISC-V Zicfiss). + source "mm/damon/Kconfig" endmenu