Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3819431pxb; Mon, 30 Aug 2021 11:20:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxu9aQVUFEf5SO0c/H+aHNb3diHt75zgWax9uyvk9+WlHXMdBdDBfPPxK/AT3Jk1obwqgf X-Received: by 2002:a05:6402:b9c:: with SMTP id cf28mr26452306edb.356.1630347643189; Mon, 30 Aug 2021 11:20:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630347643; cv=none; d=google.com; s=arc-20160816; b=EubQmEujczGdUKpwniUOizek3t2B3XKHILWLNf9zkXg5ny8/JikYk8vJBcQArYpkEW dmFacAgMQEDaGDqvKNQN4gRsGPXjOeW09Zi+gkMnEF6ovohzg0Tv0510wLxeciKYXTMy JVgL00ffd0I4ZwUZcxzyVJNNI602VHA46yj7Gwvy+HSx9xPbk4hjQxqMKZcfToGofu+u K/7JDbKi+GjgVfeCeosTqvcp0MDR6cQCVu2wL8GYUssHr2OTqecGQ3dc65bIeka6Z7Bo B+URDqEgw737smdgKG8qgV3iP3t4wjbrt76Rh7njFoPVI7cFxSYXKKULetOU9DNH/hWg XFIg== 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; bh=PqPJJTQGgv2scSEe8zpOtyG5vlwZcRSwrMHkMU8kHDo=; b=pssi8WPf/FO5bW/oUzAG9c5ZTvnu6Sp+2imR0StabIxej2cpVPrrWAU+BX980x/EHp WKVdgSNPOzRq9fr2xWLnRiJFMWHGyMFAjWnieiKw8MaAnM38dWtKIy829kspdbgP4C+a gESJo6Xvsq9rsHrD2JXvv/2T5iNWrCwqm+shqYCMrg06Xom0cCwDuSjdk9i1FyAr0C6T oQC3SPZpjs3JEJcbHehmEvrykAdvKSAs+2/Vm71JUs6Y8DqkgCqUec3aFxn8B6io6SUM 6F9SEEySVvAH4/IzDK66RF3btqn9S3RAkAXjF0aOczZeAIgTLEDEJTBamkLMf43xTfA1 RRQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i19si16161484ejw.660.2021.08.30.11.20.16; Mon, 30 Aug 2021 11:20:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239158AbhH3STV (ORCPT + 99 others); Mon, 30 Aug 2021 14:19:21 -0400 Received: from mga06.intel.com ([134.134.136.31]:23984 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238510AbhH3SRK (ORCPT ); Mon, 30 Aug 2021 14:17:10 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10092"; a="279339842" X-IronPort-AV: E=Sophos;i="5.84,364,1620716400"; d="scan'208";a="279339842" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2021 11:16:15 -0700 X-IronPort-AV: E=Sophos;i="5.84,364,1620716400"; d="scan'208";a="530533256" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2021 11:16:15 -0700 From: Yu-cheng Yu To: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang , Rick P Edgecombe Cc: Yu-cheng Yu Subject: [PATCH v30 02/32] x86/cet/shstk: Add Kconfig option for Shadow Stack Date: Mon, 30 Aug 2021 11:14:58 -0700 Message-Id: <20210830181528.1569-3-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210830181528.1569-1-yu-cheng.yu@intel.com> References: <20210830181528.1569-1-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Shadow Stack provides protection 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. Signed-off-by: Yu-cheng Yu Cc: Kees Cook --- v25: - Remove X86_CET and use X86_SHADOW_STACK directly. v24: - Update for the splitting X86_CET to X86_SHADOW_STACK and X86_IBT. --- arch/x86/Kconfig | 22 ++++++++++++++++++++++ arch/x86/Kconfig.assembler | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 88fb922c23a0..cb0405ccf858 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -26,6 +26,7 @@ config X86_64 depends on 64BIT # Options that are inherently 64-bit kernel only: select ARCH_HAS_GIGANTIC_PAGE + select ARCH_HAS_SHADOW_STACK select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 select ARCH_USE_CMPXCHG_LOCKREF select HAVE_ARCH_SOFT_DIRTY @@ -1908,6 +1909,27 @@ config X86_SGX If unsure, say N. +config ARCH_HAS_SHADOW_STACK + def_bool n + +config X86_SHADOW_STACK + prompt "Intel Shadow Stack" + def_bool n + depends on AS_WRUSS + depends on ARCH_HAS_SHADOW_STACK + select ARCH_USES_HIGH_VMA_FLAGS + 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". + Support for this feature is present on Tiger Lake family of + processors released in 2020 or later. Enabling this feature + increases kernel text size by 3.7 KB. + See Documentation/x86/intel_cet.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 26b8c08e2fc4..00c79dd93651 100644 --- a/arch/x86/Kconfig.assembler +++ b/arch/x86/Kconfig.assembler @@ -19,3 +19,8 @@ config AS_TPAUSE def_bool $(as-instr,tpause %ecx) help Supported by binutils >= 2.31.1 and LLVM integrated assembler >= V7 + +config AS_WRUSS + def_bool $(as-instr,wrussq %rax$(comma)(%rbx)) + help + Supported by binutils >= 2.31 and LLVM integrated assembler -- 2.21.0