Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp49330rdf; Mon, 20 Nov 2023 15:57:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFMgKdzO1kcEW/3yJ7n+yNgfT8kXyiTXdiJJ4C+nugAjFaYRkYUBOCKxqsmC/bPqBkuAScW X-Received: by 2002:a62:e40b:0:b0:6c4:d615:2169 with SMTP id r11-20020a62e40b000000b006c4d6152169mr1228620pfh.10.1700524632362; Mon, 20 Nov 2023 15:57:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700524632; cv=none; d=google.com; s=arc-20160816; b=kFdStAQykkxtZ5Rf4fLD0FADnffoHKyXVprv3NDDg1/j56ESPD5BRugNSpLWEiF4/f NONYyYPjosSdwF0r4uDjWaMJcddZO2fYI4bVa0jjk3Ucqb91AuGUuU+pwAIkN9r54zh3 umaKSysWtaLalu4P0GZg4xGwsf3c+qhtvw6piZvKRh6fzGSOT+VJCn9MG/2/uXIzxKfB CMCSajNye2wjX0bbQrdGZTvTKWE9B3JfU0NqilOwxzNHnJlw0pIcQg2EUuWsz9jgkXlt C9BPyfDEEsFv0m6dXNWbQ2THRYcI9XhSMICFKB20mjiZHGppEYZ43PDNO8vRwWZ3sAFw kmkg== 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=gvldWWnAZW0wjG0qyXyZSyBuNoWU63/N54N9lPf8e2U=; fh=QD8DltxdNEo4LPmCb1b9DaVqpdSmjfJB45XzRnalxtw=; b=NOJQnotpSXQz2knWiVGUfBkSpxxAwQyxuikX8BXHLhKob7IKLYJATZYZQfSqsRYjS2 syT/8+wagPjC4FD4+eu+U6tf3HbYgiT3/fo9tTiAfNmmsOiJKtT+XKPANXo+mfQZkIyT qnsO379nIQGYjXw/sVv7KbxC0som83V93/q72xCTJT72t9l+Q25bCviRinlSg06+qXL1 XEtu5jzqrHjPIGW8uxvFxnK0yD7V+e23NfbCaXX6b4FebTBKmpDoFT7ZA5Pt9urOQvh5 kFkQ96VDpLGvZanueUsgC2xz5Wxxxa6dtOL+IsXMtwo18SHcoQvXvajiyCKRm0p03jZD ubiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WV41QAv1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id g16-20020a056a000b9000b006cbb36b9060si1893766pfj.385.2023.11.20.15.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 15:57:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WV41QAv1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id E9AC480785E9; Mon, 20 Nov 2023 15:56:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232666AbjKTXzh (ORCPT + 99 others); Mon, 20 Nov 2023 18:55:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232654AbjKTXzf (ORCPT ); Mon, 20 Nov 2023 18:55:35 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09EB897 for ; Mon, 20 Nov 2023 15:55:32 -0800 (PST) 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Mon, 20 Nov 2023 15:56:42 -0800 (PST) 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 --- 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 -- 2.30.2