Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8409952rwr; Thu, 11 May 2023 00:24:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6i90x6A9U8n95/LmuFZHkPp/cAogYpCoWn9wM+oY52V3I71SxnW6dhhFxAmCTy8sJ/oYs6 X-Received: by 2002:a17:902:e80b:b0:1aa:ffed:652c with SMTP id u11-20020a170902e80b00b001aaffed652cmr26859417plg.64.1683789857979; Thu, 11 May 2023 00:24:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683789857; cv=none; d=google.com; s=arc-20160816; b=kUBJTCwaKgMkNdURMvS3UFDFYlvfbyZaVTtkyEcNXZYFV79lHIKIYtXD9SUq3n7Dr3 QPZLu7AbknEGgW4zj4L1WYTHHt2QrqpSERqGed+FAx58bYddtSVMFCztHGhSBNwQdfY0 gO8IYnlboakvUSV1KjcrXwBiOI2+T0gA1s1Lab+k8bRYTTL6u6p5IhmRBW4mqyhBVILw SqJSMA+qM/Ej/EH9D3Q3c5P7lWhSM9+aAo6tmtdMo028mxpKA5pidqVqIk36rIztE1hU 8p5ubNCYAVHLhnLbnCBfyFhEskXBemCM/HvbvPmCm4ay5BOHWNzcTx6l6mKuu/kGTftI orvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UsqvhISRt/CguHVi6xhbHsUhQIB1BzF/GvBGxi/xaQE=; b=KeMXin0F54gtFEYeRd8S42E5KumaEtbwgyArVYzfribAQ64znC0i8aCcNOrR1dwYCt ywT7jdKsGopeR0+VVUDf2JkR+Eo3vT+83mEvPxSEer4C9M9qDEFoea1q3rNBidCAEFmt Ncy/1pK5aqhz0b1qxRK8MxJLtQKf8fgNrv/SfdDJEdCpEDgVizpu0zjFqAW3jPhG2r/2 GHPhkYOELHvFCO9xtKeJzccVVrgKoROyAedKWZfY+5jObrBaQKJrIPT3Gn+W7pvmmx1r hiWwgTFx2EgGCBijMoe7GRFN8wLHJ6bL/ANu+OB3nEHt4ap0avoY7zRGjsmjoFCxmzDS naqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nL3kYCtJ; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ij2-20020a170902ab4200b001a63d8efabasi5415036plb.445.2023.05.11.00.24.06; Thu, 11 May 2023 00:24:17 -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=@intel.com header.s=Intel header.b=nL3kYCtJ; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236916AbjEKHOI (ORCPT + 99 others); Thu, 11 May 2023 03:14:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237416AbjEKHNp (ORCPT ); Thu, 11 May 2023 03:13:45 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61A1B2D64; Thu, 11 May 2023 00:13:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683789221; x=1715325221; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9rCJFBWLMwkBw9HBuP/Kc52dFcfvwQjY//PWWGqH99k=; b=nL3kYCtJZU7xl2UfJDbNCXQyKxi60qUuPPgHeWTKO1UXrCABTzfutHKQ zBGttV75gMcSD1lxifNTUqn+T2+XaGuZSOiFygEoNiRGfEsmu57W7L2Ai DDURLnkMRnPy69e3ItXg16GXz9PUHWFYR/hL6tcQ1VK6c3UNv2Jc4VwB4 GqMQ5AQtMm5FQ0xcuFrLOstUXeLTRKH9/qyusDz9CCYSL2pnyRAPeG0Vl dx8h/H25kZ+KUizdUdCEcWnGJtme5fFPkU5TL5FrsBHOOj01M06umudIQ dgIMvDkZycHyourlDQBS6DNnT5TiueS8uNbFDSoplHMnYKHlF5XB6Ip+M g==; X-IronPort-AV: E=McAfee;i="6600,9927,10706"; a="334896592" X-IronPort-AV: E=Sophos;i="5.99,266,1677571200"; d="scan'208";a="334896592" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2023 00:13:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10706"; a="1029512341" X-IronPort-AV: E=Sophos;i="5.99,266,1677571200"; d="scan'208";a="1029512341" Received: from embargo.jf.intel.com ([10.165.9.183]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2023 00:13:22 -0700 From: Yang Weijiang To: seanjc@google.com, pbonzini@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: peterz@infradead.org, rppt@kernel.org, binbin.wu@linux.intel.com, rick.p.edgecombe@intel.com, weijiang.yang@intel.com, john.allen@amd.com, Yu-cheng Yu , Borislav Petkov , Kees Cook , Pengfei Xu Subject: [PATCH v3 01/21] x86/shstk: Add Kconfig option for shadow stack Date: Thu, 11 May 2023 00:08:37 -0400 Message-Id: <20230511040857.6094-2-weijiang.yang@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230511040857.6094-1-weijiang.yang@intel.com> References: <20230511040857.6094-1-weijiang.yang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,DATE_IN_PAST_03_06, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Rick Edgecombe 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 a825bf031f49..f03791b73f9f 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 b88f784cb02e..8ad41da301e5 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 -- 2.27.0