Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp848191pxv; Thu, 22 Jul 2021 13:56:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDu76MeAYASmcUyctIDqR8apGAV5xriz8QFsuybAk5vAlNW5zOW7+v+BSZtjoamVAt6Iom X-Received: by 2002:a02:942e:: with SMTP id a43mr1293084jai.74.1626987372494; Thu, 22 Jul 2021 13:56:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626987372; cv=none; d=google.com; s=arc-20160816; b=VZDKA3lNaIl+jfu2DMHz37y4/ih71+W+5uz7zP54nxU7pw/HiqxS6cQCKCHAqaVWRm CMWrup/EgBmSLocagQ1+q400xAj7ehtIMFH3hoUwJDXg7kv6/NQCoZ/6aqiXY9EzhxDZ XL8WxX12wetqUM+Bt1s9l2TmwUy5LR/LjwcaO+7CclJagHBu/On2PC+yGvwu0XNDd1fG TKFGujPVIW2qa3Z1LS31v0cKN0wgj/w07IzymQXCg8rE7HLFO049L7XxN8/0PJHDXWWj CaliqrN1xekl7G+rDk41EkaeTka1F1ZmFPUZBGJIAK5zfmYblAFMvvZakrxjgDgiH5AY RoMg== 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=xPH49dQB+YrQengFOYlqnR3qJ8uSdMose1wt8BrF+Yg=; b=VpEtIGWY5lK3AxQNRLLUVqXk8Qd8mWwbarP6/b59CRqFpNAF2xdFisUJpBdyQd9nH9 MQ2twgfVMSbUzBa7XDvqW3dbl9KC0NIEqiUb34pxqvk8CRNcOQ4swLyiAVSVYOWcBipc vZAJvpkNTSSSsSjMhAsdYu9TbnwFPt9xuH4+hizxwH/GIzKW4bKzH3r4yyxCN6OP0mUc jrZYpf0sc7AN1NJsoVo9OkE5yA4iU4d2MeV/DWJGAvsybcmIJ8mtBx/MwF9fO4j1hbYD JpPs+CpiCIvBu/oQn6rCaW0Ba8XwJW7jxE1iP7zvf3o9Ch3+3m2ITioiLO0fXaUaX7HP Kmlw== 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 b39si21542805jav.0.2021.07.22.13.56.01; Thu, 22 Jul 2021 13:56:12 -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 S231590AbhGVUMk (ORCPT + 99 others); Thu, 22 Jul 2021 16:12:40 -0400 Received: from mga06.intel.com ([134.134.136.31]:22178 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231135AbhGVUMY (ORCPT ); Thu, 22 Jul 2021 16:12:24 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10053"; a="272854671" X-IronPort-AV: E=Sophos;i="5.84,262,1620716400"; d="scan'208";a="272854671" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2021 13:52:57 -0700 X-IronPort-AV: E=Sophos;i="5.84,262,1620716400"; d="scan'208";a="502035412" 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; 22 Jul 2021 13:52:57 -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" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang , Rick P Edgecombe Cc: Yu-cheng Yu Subject: [PATCH v28 02/32] x86/cet/shstk: Add Kconfig option for Shadow Stack Date: Thu, 22 Jul 2021 13:51:49 -0700 Message-Id: <20210722205219.7934-3-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210722205219.7934-1-yu-cheng.yu@intel.com> References: <20210722205219.7934-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 49270655e827..de992d3408b2 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 @@ -1909,6 +1910,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