Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4055935rdh; Tue, 28 Nov 2023 10:31:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFikoAo7Y9rwJ20zC9FRHPxg8+qerv9IQON9078nlJY49BXrKEd0b4huXZqE9Zkju3LayHS X-Received: by 2002:a05:6870:1d06:b0:1fa:26e7:c428 with SMTP id pa6-20020a0568701d0600b001fa26e7c428mr14320979oab.19.1701196317086; Tue, 28 Nov 2023 10:31:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701196317; cv=none; d=google.com; s=arc-20160816; b=1JF50+5HlGuu+7XbPuuWPUezrTMvkAjTg+TvoSPuwC06RzKPeodbl2KsPUeY+lhKno LmYLL/+zvLOJ2V/RJkIgu+hx5o3JrlwKcu/hKeeS82BcJWE1Y0gWepTd1ywlZpRj9+xX wCQyaXHcizFVkd3RXxPuubm8XGxjNrMYc4zoz3K4SP8y0woy3CIaHiHp17hqQrUURM8z AXFmS8FiqP26jnXosAGKWPK6K0yQ1h4wTPscYWNAEsniEb9LcL5pAITPUbA7nY2aScw5 5LJyCBVSjpuQao+vt687cTy9CIjK3RSybxjFAeNekSxk8UyrInYZqjRpwLn7hyyzRuoB iOiw== 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=yZWjA5hu2Df0wh88zHo3Hl30HjX3iVxcvk4VljBARS0ybszMqxHfORms+RljF+nsMo /ahjHYWV0QRLUHO6nr03s1O+AS0sK7lkj+k9Uv41aKVpsATg3ynriHlz99/BxKJmylz7 4UTTQJtoRq8a/aRHR76iJRIzEaDIucQLYqjx7nLc8FDd/FpasLHkemfnOGstE+JQ9cYy M8DawZIfCTwd/i3g9cE1Nt+8L8qE1WXQOHs+wiw3ZH5VxJS8F0PmqeqmV+eZpDIje1GY 5w5pqBS3zMBllkGerrFO4nmSR+Rgzw4evVVEeoWRxvdKc003xVQ3df9RAVuf9kSeVgmG Tu2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vQGSXBCq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id c16-20020a056830349000b006d803c39f49si5111292otu.10.2023.11.28.10.31.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 10:31:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vQGSXBCq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 918A880A7CE5; Tue, 28 Nov 2023 10:31:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346076AbjK1Sbk (ORCPT + 99 others); Tue, 28 Nov 2023 13:31:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346027AbjK1Sbg (ORCPT ); Tue, 28 Nov 2023 13:31:36 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 402501AE for ; Tue, 28 Nov 2023 10:31:42 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16881C433C9; Tue, 28 Nov 2023 18:31:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701196301; bh=FEKtInmB6mFDaJj7WRZ2UJIP9/hPzlhQkMpJUP8BQq8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=vQGSXBCqvGEMZ2UGNc/k3sueJ/0xAn0JGZtWRTeJMW8QfxGKGCUlbFfyVQ/kXxAL7 aHorcGPy4fzLwczlDEqpeBm86lGWyL/bGpyrvgpa0WT4u3/P5GJkanYDkj4cIgnZtK nXE2VMVNDIjhFxafrFuG4CH8TFA9O2tCQQo4OzKQk0q/FkDP+L63IeKqsO8KI10PZH Ad002X3tuMULKYoR/Q/VEGrJYaxMM1VZpwF8XhAsfpNZeMKLT9FwqMmT6XXpr3WmTD 9B2eqqRQCjHcY1CJoQn2+R8vawiZpc7TSH/lpvr42zF5GJHEhCyRtwJSam6oDzCH0u gR4T5fZJAyTUg== From: Mark Brown Date: Tue, 28 Nov 2023 18:22:39 +0000 Subject: [PATCH RFT v4 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: <20231128-clone3-shadow-stack-v4-1-8b28ffe4f676@kernel.org> References: <20231128-clone3-shadow-stack-v4-0-8b28ffe4f676@kernel.org> In-Reply-To: <20231128-clone3-shadow-stack-v4-0-8b28ffe4f676@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/pANAwAKASTWi3JdVIfQAcsmYgBlZjH9q/8Nlzp/TG+PgL0EvlGN8OLT68zSuMbPXhVL bnUpawSJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZWYx/QAKCRAk1otyXVSH0CnMB/ 9p+BnvjI0CIzEWBV4qurYBRenRV4sjx4O7HYkpsWjqGHePRDmKVr88xJ433w44HMaBhcQU8hEx+CkQ 2D5qU8DfgX/f0wMdog1UL80/3U1pST30q10lc6apfD58b9oxt0qCMKtklP5i4PdY/AFlcPoIRmhe+V E4We3sX9dmV3tr26I8frU1NvYKabv8aPYLtBix25xh84y0rWrPxD2OfXUDuTzE8gyVUhnoQZ79G0Kr AQw2VJX0LwZXHCrj8vi0bAV6ZG+PUqbLvUlzRJnwvi8my+aiw5alLBPJg4iW4SGckAkFYzhzLY+hk5 LHpbCzabhZnIHRLp2D43SJyprTblfr 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 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]); Tue, 28 Nov 2023 10:31:54 -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