Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp606568pxb; Wed, 27 Jan 2021 16:33:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlUqH7nvnb4vFThKhL/LLFGTbeENJM4bPLIlWQDKwr58UyJOLpfPStTwJBUlnblklRp5g4 X-Received: by 2002:a50:d58c:: with SMTP id v12mr11162056edi.71.1611794032712; Wed, 27 Jan 2021 16:33:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611794032; cv=none; d=google.com; s=arc-20160816; b=1JKA/x87ywqi/Ib1wWuAkbWXMOJLlAplgaEaZP3Yv8hKUQxi+J+PnyNEkXVMNiDWEQ uw8h6Jm5BIbEG0HvsA8WscakhuhoOPvj4YPMMTYAuCiREkgOYzO56B+SuKRKh1Sd/imu CibTJwxiAwWp2O1OlE507AdPH4EIbHoFKaD88ie3xdzEUkfTcprCkk7jKoQHA3+vdh1r dCRN2oU2N6QqEysKznD/u3jYKbEz9mZmY+A97xiU/NHFvapyG+07jAwVUdXV1CAGT3Tt a3M9W/HT8j3URJQs5+8hBIofLVzfpFq5WJQ++4pDuKB6GPYuWF/evGHGPAlK8HlLmaUN nAqg== 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 :ironport-sdr:ironport-sdr; bh=OSsOadcPgcPQxDIclWkImR4ueC4JLoTsMTzD3IiusmE=; b=HNCGKdAQfSJIp82An7pzPJYFBsuTFjj55zyh5aXnQFIamzbnV/5TgGvclE5cr2W099 c8BqllSbP0AmsdB+88W+89rmsH2kHs7JzfpkaqQxnu6rVl+q4aMzoyMQhdTCu3XcqH6O 1N1TmYH+BW1vixUeEP8PUSZfRJvkBza3/BKf4zsm3pmeQpfpwey/GlGdO/1Sxzv5kq/Z lAviFlBNFpfqqt1rqlbrd46Ee/i683F164xFSl+zAcxp0mQTUfBfHGK3DIqi47kK+aB0 e/2V1VUJB97LZg/8CCPvGXgW6Fr6oy4NzVEnIAz96AitbMZ/t28A0DgDxF5kSyl3/3vP bfrQ== 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 d24si1223499edt.102.2021.01.27.16.33.28; Wed, 27 Jan 2021 16:33:52 -0800 (PST) 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 S234149AbhA0V2G (ORCPT + 99 others); Wed, 27 Jan 2021 16:28:06 -0500 Received: from mga04.intel.com ([192.55.52.120]:48884 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234462AbhA0V0u (ORCPT ); Wed, 27 Jan 2021 16:26:50 -0500 IronPort-SDR: 1Zd46pBw+eziIx0cYW1wxHOMPNqKo2Y8AKBd/JJn5KWoQi/CrCZ030NxxnUWOSkW+uha0mIw6e gSZof/rlK5YA== X-IronPort-AV: E=McAfee;i="6000,8403,9877"; a="177573098" X-IronPort-AV: E=Sophos;i="5.79,380,1602572400"; d="scan'208";a="177573098" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2021 13:25:49 -0800 IronPort-SDR: D4aDZfyvo1J+7UBhOQ49iNv7JhMiCuGG+vToy+qRFwayXLng2xzMnNfgwlbNXvFOqgPMTk+lub v9NRQYJZNB5g== X-IronPort-AV: E=Sophos;i="5.79,380,1602572400"; d="scan'208";a="353948187" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2021 13:25:48 -0800 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 Cc: Yu-cheng Yu Subject: [PATCH v18 02/25] x86/cet/shstk: Add Kconfig option for user-mode control-flow protection Date: Wed, 27 Jan 2021 13:25:01 -0800 Message-Id: <20210127212524.10188-3-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210127212524.10188-1-yu-cheng.yu@intel.com> References: <20210127212524.10188-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_CET 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 --- 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 21f851179ff0..2d080a2335df 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1951,6 +1951,28 @@ config X86_SGX If unsure, say N. +config ARCH_HAS_SHADOW_STACK + def_bool n + +config X86_CET + prompt "Intel Control-flow protection for user-mode" + def_bool n + depends on CPU_SUP_INTEL && X86_64 + depends on AS_WRUSS + select ARCH_USES_HIGH_VMA_FLAGS + select ARCH_HAS_SHADOW_STACK + help + Control-flow protection is a hardware security hardening feature + that detects function-return address or jump target changes by + malicious code. Applications must be enabled to use it, and old + userspace does not get protection "for free". + Support for this feature is present on 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