From patchwork Mon Mar 20 16:39:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 72325 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1344847wrt; Mon, 20 Mar 2023 10:41:01 -0700 (PDT) X-Google-Smtp-Source: AK7set+QKHx7IvNPC9cp+fiaYGXUd5HxU2k4V9nI3oiv8vjFT0Bux+N1nJ1X46i8NfckkDZ6VFP0 X-Received: by 2002:a17:902:e551:b0:1a0:65d3:bae4 with SMTP id n17-20020a170902e55100b001a065d3bae4mr20692392plf.38.1679334060770; Mon, 20 Mar 2023 10:41:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679334060; cv=none; d=google.com; s=arc-20160816; b=oAzRXGN3Qc1Jft9D6JiXZt4/FytwHYpfKzmz6E4NBj1HgmV3VoKQVRtilwIxKS9OLP FKAv8ohjQ1M70XSmGBrukwPsm/t8x8QcpSNnbVclbAsTyDVf97T20aLsSfv9+fiJ7oNN 81b4jtbHGE386ZVGq5j/JelLQTsHPNFchJUPNf34pAchfzt5bAiY9QcJTvq4RC3a7WuK pzyxjvJw4CwRtBNbUZDgzugaD8Y8mAxD1eWhG1InNRmRRiyXLD5/ofBFtAabN7kcQ+6F miC+nmLALM24W1JVTxp7xkR0x9L7jKsoC/m6L/sQmGkWiofLJweHSUpTeoJoFDwmWCiU Xh+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=SoWgfdBCQFXYRXc2gw3EFfiFz85wh0sWzg6rAlffUUo=; b=pv7gXwr/IfSiUj9AN7dfeUOWVxn0kc0cisxKUurY/hICPTtKw2M6mT2OPgzu9iXOrQ rRXcAVfA+r4Ns8ylCtzubanMpMArp2dQVlfKvhovomFUC6GrClQ71QLGfhv//EVriC+8 I8a0jlIJ9/bkw2Vu1kJH32A5L7h+qp4j/Ax8kkhXvIl3lZXj9U7tSH1LB46aZHh6vusX Ucltj4K/FO3OHB7T/FpDddnza2GiTAHojdPgKO9QaHzjjRSncAn9fXwA5KAjF7Wu4NXF 9r5X9rNW5Tn224qVVUCFXa+0ufdJWdE+4YBLOXQG7xliw6lf3sks4XPwN974vuIFMoqh alFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="tFcX9xz/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m1-20020a170902db0100b0019a96849d6dsi11866891plx.605.2023.03.20.10.40.45; Mon, 20 Mar 2023 10:41:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="tFcX9xz/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232876AbjCTQvA (ORCPT + 99 others); Mon, 20 Mar 2023 12:51:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232941AbjCTQty (ORCPT ); Mon, 20 Mar 2023 12:49:54 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B5264C06; Mon, 20 Mar 2023 09:42:20 -0700 (PDT) Date: Mon, 20 Mar 2023 16:39:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1679330371; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SoWgfdBCQFXYRXc2gw3EFfiFz85wh0sWzg6rAlffUUo=; b=tFcX9xz/+SUIhaY8xGfjC8ZXOruu/9/PIVwjffQ4xZkNXxmAE/Ve9Q0kRK4uT6cpt/nz5K KUjzGStuiaFqGb78R7OwpSEpPwBW3rvuomeisTUEXpBEYnO3mlglvfcxoJL5mqzWOnAjnm obyutVBFJIkVtv0mgFaauEPaTa1dbzqbEgmjNNUb09GbvoHOODNAycKibgz6ozQ9NK+ELz ByFCR7qNjA94hU2dILijUfC5j+AbtDU1jA4GUXtNODSHV6hcEBu0uPbV2Vt94eP2qPaU4o Xbk6Ow2SdwvyDVCfVNfCk95Bwsmp8p2BMNTbghInhnt5Fv1AL6qo1bBrNuLYEA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1679330371; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SoWgfdBCQFXYRXc2gw3EFfiFz85wh0sWzg6rAlffUUo=; b=G+ITuhvMgbxxTfADnY6kDHw0ohsuHsifkWDz0K/8GCNdXUipw7qnKmJKZIjvkBx3iL4AhZ cRYZ9OjCnaZbb5CA== From: "tip-bot2 for Rick Edgecombe" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/shstk] x86/shstk: Add Kconfig option for shadow stack Cc: "Yu-cheng Yu" , Rick Edgecombe , Dave Hansen , "Borislav Petkov (AMD)" , Kees Cook , "Mike Rapoport (IBM)" , Pengfei Xu , John Allen , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <167933037103.5837.11623929936150441742.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760909391874687983?= X-GMAIL-MSGID: =?utf-8?q?1760909391874687983?= The following commit has been merged into the x86/shstk branch of tip: Commit-ID: f7dabb27de62e121afc32c44748328841249e68f Gitweb: https://git.kernel.org/tip/f7dabb27de62e121afc32c44748328841249e68f Author: Rick Edgecombe AuthorDate: Sat, 18 Mar 2023 17:14:57 -07:00 Committer: Dave Hansen CommitterDate: Mon, 20 Mar 2023 09:01:07 -07:00 x86/shstk: Add Kconfig option for shadow stack Shadow stack provides protection for applications against function return address corruption. It is active when the processor supports it, the kernel has CONFIG_X86_SHADOW_STACK enabled, and the application is built for the feature. This is only implemented for the 64-bit kernel. When it is enabled, legacy non-shadow stack applications continue to work, but without protection. Since there is another feature that utilizes CET (Kernel IBT) that will share implementation with shadow stacks, create CONFIG_CET to signify that at least one CET feature is configured. Co-developed-by: Yu-cheng Yu Signed-off-by: Yu-cheng Yu Signed-off-by: Rick Edgecombe Signed-off-by: Dave Hansen Reviewed-by: Borislav Petkov (AMD) Reviewed-by: Kees Cook Acked-by: Mike Rapoport (IBM) Tested-by: Pengfei Xu Tested-by: John Allen Tested-by: Kees Cook Link: https://lore.kernel.org/all/20230319001535.23210-3-rick.p.edgecombe%40intel.com --- arch/x86/Kconfig | 24 ++++++++++++++++++++++++ arch/x86/Kconfig.assembler | 5 +++++ 2 files changed, 29 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index a825bf0..f03791b 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1851,6 +1851,11 @@ config CC_HAS_IBT (CC_IS_CLANG && CLANG_VERSION >= 140000)) && \ $(as-instr,endbr64) +config X86_CET + def_bool n + help + CET features configured (Shadow stack or IBT) + config X86_KERNEL_IBT prompt "Indirect Branch Tracking" def_bool y @@ -1858,6 +1863,7 @@ config X86_KERNEL_IBT # https://github.com/llvm/llvm-project/commit/9d7001eba9c4cb311e03cd8cdc231f9e579f2d0f depends on !LD_IS_LLD || LLD_VERSION >= 140000 select OBJTOOL + select X86_CET help Build the kernel with support for Indirect Branch Tracking, a hardware support course-grain forward-edge Control Flow Integrity @@ -1952,6 +1958,24 @@ config X86_SGX If unsure, say N. +config X86_USER_SHADOW_STACK + bool "X86 userspace shadow stack" + depends on AS_WRUSS + depends on X86_64 + select ARCH_USES_HIGH_VMA_FLAGS + select X86_CET + help + Shadow stack protection is a hardware feature that detects function + return address corruption. This helps mitigate ROP attacks. + Applications must be enabled to use it, and old userspace does not + get protection "for free". + + CPUs supporting shadow stacks were first released in 2020. + + See Documentation/x86/shstk.rst for more information. + + If unsure, say N. + config EFI bool "EFI runtime service support" depends on ACPI diff --git a/arch/x86/Kconfig.assembler b/arch/x86/Kconfig.assembler index b88f784..8ad41da 100644 --- a/arch/x86/Kconfig.assembler +++ b/arch/x86/Kconfig.assembler @@ -24,3 +24,8 @@ config AS_GFNI def_bool $(as-instr,vgf2p8mulb %xmm0$(comma)%xmm1$(comma)%xmm2) help Supported by binutils >= 2.30 and LLVM integrated assembler + +config AS_WRUSS + def_bool $(as-instr,wrussq %rax$(comma)(%rbx)) + help + Supported by binutils >= 2.31 and LLVM integrated assembler