Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1222615rda; Mon, 23 Oct 2023 06:26:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDiU+w7+ydK290tbKNxJcHt+2yOOYvOjKwY/CH389FkuuxHFFo2pVE40t5GBEiDsNkeRnj X-Received: by 2002:a17:902:d054:b0:1bf:557c:5a2c with SMTP id l20-20020a170902d05400b001bf557c5a2cmr5697858pll.44.1698067583217; Mon, 23 Oct 2023 06:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698067583; cv=none; d=google.com; s=arc-20160816; b=qaNebZxr0+xpw44M9o5ElAzts5RchLhTKRt/18P5dz6OQxd/Et/vy61S+29wlsbZ2O +0Sp7o36elgw/p0ZjuEb3UICY4n9DkacFsj0/Cw/qXuxAuJ0t2+pW+ImL0sro5UY4lbV s6RGVWeW5EAXBmqoGs9w4OJ9mOGBG63ePv0h9FDzLltA1gnfMMxjdVK8gcPVuefp/N8S Pk8xgJQDQ5Y743dO64nMQ7tLPqJoDq8n4DW3hQs8mSFohazH6a0HM1Zi6KIpmov2R97g gGDI9oMb6IWZ2MqGgQvQAah2YRQPThJQhO0B8spGfxkhNi01pPxwz/Mr5zFIOI4gDpSA /shw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=H4b3izvVB7swdgRHB/NCsypb36rHp8QNc5MNTLfi0xo=; fh=xFMWs1gK6slT5dlENMZ9fIsAvT54ZpekIZZMDGSej6k=; b=SRs7CXrQjYQX4LWSrd7/AojbqL73LEXtcNlBaa5j3x22GuZ2XUVztJjfF/yVh4iKB6 zmVbkyd0wqZr0vq02VkIHk4uv1Tj2FYmaXJ0naNGbrjgmN3OpViseSZrIdX0zntgTTat tnU0NKXvfkx3HykSGVuMefr6PfI1mIH36ToW8kJ1ZpsfsQBD+Vpcg7RWSXVtQkEwEFNc /MVLnbMixQUMwh45/aZ97IOSQFoVljZQ14ddp7ZYFLVD2Z4upS1EW7HNpwXYV7qSzF+A 574gGuihOBGMiHNW6W1gcC26mg977nsJju5Rhjn4zbXRQoimk+6kUWUJplJ1ZoFKUKg7 yMAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PUfhQYxG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id jm17-20020a17090304d100b001c9b3c3ce7asi6157148plb.300.2023.10.23.06.26.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:26:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PUfhQYxG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id B431C80AC5A9; Mon, 23 Oct 2023 06:26:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231361AbjJWNZy (ORCPT + 99 others); Mon, 23 Oct 2023 09:25:54 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 23 Oct 2023 06:26:20 -0700 (PDT) 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 -- 2.30.2