Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp37717imm; Thu, 30 Aug 2018 07:48:55 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZt2gdNCJDIa/2a2j+8gdncMc7G1qfNVMclre89mJI1uyp/EeQc0KeaxNQX6gUvCHfcub7/ X-Received: by 2002:a63:d401:: with SMTP id a1-v6mr7874812pgh.414.1535640534932; Thu, 30 Aug 2018 07:48:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535640534; cv=none; d=google.com; s=arc-20160816; b=CPUYaMZFNli9QubfoAZuEcULtwt9VftZfnY8cLeW2ifb0JTvDm5Q3yq7UP5JsdFo37 4r/OU+J56puyLyTZlJmh/g40mVvA2r/vSktMuMhQla+ERbyIbtwG4qss4wHkOmW09r0B JrtNZMrRTkSX09ZPMPjFPiaxBqHYZgcSrthFlJNz1j4yE2DaCKqZ1ocYhasrNv4NTW5W 3IdUKguC9Hlq+kgPE+3EHzpJvRIT9fWQqOF/QqysBNpLs5ORaBx20HaNKu4KRFVwbyU4 Tz8q2o+moMt5Q9HpYPVsSKuTYRjR4tbc4NKSybGITBx0RKwYx4EVXfXdGeWrpzfY5zs8 WInw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=k4ilXAgtM4WeGMdX7a31F8vTlTq5Mx7cW6GXmMEayEc=; b=D4wyMAYejdB1ze6Uv7i0NoY96EwLCOHORnIXj+P+gHV4qr8HnrnxP7xewpI/7DGp8V 9Is5Q0pfp2K+x0SZwKWDCjOzlhRWuQfJgHunomk2HE6wL0YldT6z3g/dzUFqFo9NNCdC aSUebfFy48xAg48mgWNLOYdxG/uwRxXUyLUiBTJnKu+4fQbsa+A5ViZdHBAIXbLLul9m HKrqSK5VovBYmJJ1MYhsmSCwmc6mjuxSrPS05JpPSRXCbrBCddB59EGiBi80ulRTryvi +deSrNaregz60dCSfFirSZJRvtgTkG/b1SuhuH/AATaAmNNXyNVmDT+gDrg5lVBWUeAP O+Ig== 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 a1-v6si6577954pgg.326.2018.08.30.07.48.36; Thu, 30 Aug 2018 07:48:54 -0700 (PDT) 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 S1729875AbeH3SsP (ORCPT + 99 others); Thu, 30 Aug 2018 14:48:15 -0400 Received: from mga01.intel.com ([192.55.52.88]:38430 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729224AbeH3SqS (ORCPT ); Thu, 30 Aug 2018 14:46:18 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Aug 2018 07:43:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,307,1531810800"; d="scan'208";a="67186683" Received: from 2b52.sc.intel.com ([143.183.136.52]) by fmsmga008.fm.intel.com with ESMTP; 30 Aug 2018 07:43:40 -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 , Cyrill Gorcunov , Dave Hansen , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , "Ravi V. Shankar" , Vedvyas Shanbhogue Cc: Yu-cheng Yu Subject: [RFC PATCH v3 07/24] x86/cet/shstk: Add Kconfig option for user-mode shadow stack Date: Thu, 30 Aug 2018 07:38:47 -0700 Message-Id: <20180830143904.3168-8-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180830143904.3168-1-yu-cheng.yu@intel.com> References: <20180830143904.3168-1-yu-cheng.yu@intel.com> 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. An application has shadow stack protection when all the following are true: (1) The kernel has X86_INTEL_SHADOW_STACK_USER enabled, (2) The running processor supports the shadow stack, (3) The application is built with shadow stack enabled tools & libs and, and at runtime, all dependent shared libs can support shadow stack. If this kernel config option is enabled, but (2) or (3) above is not true, the application runs without the shadow stack protection. Existing legacy applications will continue to work without the shadow stack protection. The user-mode shadow stack protection is only implemented for the 64-bit kernel. Thirty-two bit applications are supported under the compatibility mode. Signed-off-by: Yu-cheng Yu --- arch/x86/Kconfig | 24 ++++++++++++++++++++++++ arch/x86/Makefile | 7 +++++++ 2 files changed, 31 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index c5ff296bc5d1..017b3ba70807 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1913,6 +1913,30 @@ config X86_INTEL_MEMORY_PROTECTION_KEYS If unsure, say y. +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 X86_INTEL_CET + select ARCH_HAS_SHSTK + ---help--- + Shadow stack provides hardware protection against program stack + corruption. Only when all the following are true will an application + have the shadow stack protection: the kernel supports it (i.e. this + feature is enabled), the application is compiled and linked with + shadow stack enabled, and the processor supports this feature. + When the kernel has this configuration enabled, existing non shadow + stack applications will continue to work, but without shadow stack + 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 94859241bc3e..00927853e409 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -152,6 +152,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.17.1