Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp565179ybv; Wed, 5 Feb 2020 10:22:08 -0800 (PST) X-Google-Smtp-Source: APXvYqyIBgoDWFOiXGjJscrS4d4MCPg3fzcHiH6MycU2T6fwNA2iNUrqK9TliCFNTCdYn5kZ9Adi X-Received: by 2002:a05:6808:aac:: with SMTP id r12mr3997771oij.59.1580926928595; Wed, 05 Feb 2020 10:22:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580926928; cv=none; d=google.com; s=arc-20160816; b=zwfKnT/wqf3BWN+1AYY7xnfqFo3Zz/ueLYiHCj5bYZlvimZ0mpm0Ei4MGuaZQpzUD1 dnf0WtmzMGbOhHei8cE04NTJoxRzMApm9Uz3BbxZEYug4PQWz4OfaqXB/q4K/Fa59vhO brZuTaaXWofiDdLXV9VQFIvP/YNnOIZklSBhC8FUhe9BaMGegb+2rdO/FDze65raH5o7 Ru/73RRnBNV3+aPo0kppIE8SUIE4GdWkj2gxURLFDCG16t6qZZPTP+nqDkr9yifuwDR0 Wr14CvbgGQgKKVtD4S9rCXCtOEgGJOtXZXAdN36SrhnThr2wAwwnqtsrUdacwshEiolw 94Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cuasm8dl911H6fGFuxFqgxrACD1VK+3ychbloKWwhhU=; b=yPZsAZBFlniVnHszugP1Rq5NYRcVYbBI9Pf/TNBkQvTRAHX20skdcmTDcjIg1wtirR pDrBBvCyPjGzocjxejlZ9ds04PRqBuX+K5ZFe7prkTfEUGdk/OjDMEyyW4/mvBH/ELxB gEwKtlDN3hN+R8Ou0YLFIIEKjFA+CAXm4UAy9DfI/HeTb6GaJGy5NALW3gsd0d+ZIqau csmlUSZmcpMh2BEfd0HUYglSVcmFZ8uHTknajT3FasghDDYBpWE/gjZMWPqLK6hB6Pvb 0VQYJyPV29zRAK/bbUTMYqfbsrpv294Tsp3YJbGdUhTdPZtRtD/TUGJpt0OkEJC770PB Aj0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id i15si523923oik.46.2020.02.05.10.21.56; Wed, 05 Feb 2020 10:22:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727898AbgBESUh (ORCPT + 99 others); Wed, 5 Feb 2020 13:20:37 -0500 Received: from mga14.intel.com ([192.55.52.115]:20934 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727768AbgBESU1 (ORCPT ); Wed, 5 Feb 2020 13:20:27 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Feb 2020 10:20:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,406,1574150400"; d="scan'208";a="279447755" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by FMSMGA003.fm.intel.com with ESMTP; 05 Feb 2020 10:20:25 -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 , x86-patch-review@intel.com Cc: Yu-cheng Yu Subject: [RFC PATCH v9 05/27] x86/cet/shstk: Add Kconfig option for user-mode Shadow Stack protection Date: Wed, 5 Feb 2020 10:19:13 -0800 Message-Id: <20200205181935.3712-6-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200205181935.3712-1-yu-cheng.yu@intel.com> References: <20200205181935.3712-1-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce Kconfig option: X86_INTEL_SHADOW_STACK_USER. Shadow Stack (SHSTK) provides protection against function return address corruption. It is active when the kernel has this feature enabled, and both the processor and the application support it. When this feature is enabled, legacy non-SHSTK applications continue to work, but without SHSTK protection. The user-mode SHSTK protection is only implemented for the 64-bit kernel. IA32 applications are supported under the compatibility mode. Signed-off-by: Yu-cheng Yu --- arch/x86/Kconfig | 22 ++++++++++++++++++++++ arch/x86/Makefile | 7 +++++++ 2 files changed, 29 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 5e8949953660..6c34b701c588 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1974,6 +1974,28 @@ config X86_INTEL_TSX_MODE_AUTO side channel attacks- equals the tsx=auto command line parameter. endchoice +config X86_INTEL_CET + def_bool n + +config ARCH_HAS_SHSTK + def_bool n + +config X86_INTEL_SHADOW_STACK_USER + prompt "Intel Shadow Stack for user-mode" + def_bool n + depends on CPU_SUP_INTEL && X86_64 + select ARCH_USES_HIGH_VMA_FLAGS + select X86_INTEL_CET + select ARCH_HAS_SHSTK + ---help--- + Shadow Stack (SHSTK) provides protection against program + stack corruption. It is active when the kernel has this + feature enabled, and the processor and the application + support it. When this feature is enabled, legacy non-SHSTK + applications continue to work, but without SHSTK protection. + + If unsure, say y. + config EFI bool "EFI runtime service support" depends on ACPI diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 94df0868804b..c34f5befa4c8 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -149,6 +149,13 @@ ifdef CONFIG_X86_X32 endif export CONFIG_X86_X32_ABI +# Check assembler Shadow Stack suppot +ifdef CONFIG_X86_INTEL_SHADOW_STACK_USER + ifeq ($(call as-instr, saveprevssp, y),) + $(error CONFIG_X86_INTEL_SHADOW_STACK_USER not supported by the assembler) + endif +endif + # # If the function graph tracer is used with mcount instead of fentry, # '-maccumulate-outgoing-args' is needed to prevent a GCC bug -- 2.21.0