Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2317266imm; Thu, 11 Oct 2018 08:25:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV63El9y/og7M+HkT6Vzk2wRUgDQ1Bu+yuxgWfmoa+jos01B/9kY3tT4O8FffiRH8OgTzDesA X-Received: by 2002:a17:902:27a8:: with SMTP id d37-v6mr2023371plb.318.1539271521398; Thu, 11 Oct 2018 08:25:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539271521; cv=none; d=google.com; s=arc-20160816; b=SRml62euo63PHWYtHoMIeBIymoGHsFhNNemucK0+GIY7vdCI1qkD9Qxqih1qDe291o 03BjXA8QpjAPCzTNWc2tAOOzPDKJLQmdLgeR+lgI90W8SRq1LFHWelzLI9Hw3d5UQIRX 6Kjs4JbMpSE2ayojbOUIpZVBdimpYHPQeu16/HOXg8OUYaoJnCj/OqonN+zyNEV4ayCA 0ivkNDdS/fGVbXrJZzQoA8Jyx0as+A3DK0I0HKtKIIuTbsdbQKyrlFOTbCbalapbXBsr Ngkz/q8vFGms5ISHgwm70Y0rM2iESx6AQwpKzD6bSlIoiE3IrHf9dblh0yIRINtHNo6N +PUQ== 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; bh=McdE7yR3ZVq5AQz5HphRhWAyx0AF717bYF00gYIP8+Y=; b=AeNDoLfTv+/Zw5sgMlDmWFdFoZlFT8YZEDvfY7PSDDQGSCWdahOC6ltKl9WhrFXnN3 Ofxls0Xpc4z5HRkYE52eN2YitgZKfPn3A0xjv4ng3eaCbi4CefNatUH1TPkqq2y7vlUM tf6k3rKLC8DXM6hffKdzor9bAr5NoewDhEXSiPm0ffjoIJZSMX5s6AIrQl/kGM4KVFC4 hBxWzNnDfN0xz3Eok2BH4kRPg3gPnLce5Lv2Z8hDvBFAk/9USTyqQy00Lv68QKEw8rbh chzuW/f7qP4KwBw9M/wgfbNdOOT4LcdAdmRUAmR7Nl3JU0IWBdCSeLFeFbXMEQBl6aJS f4fw== 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 b13-v6si31583072plm.275.2018.10.11.08.25.07; Thu, 11 Oct 2018 08:25:21 -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 S1728439AbeJKWsZ (ORCPT + 99 others); Thu, 11 Oct 2018 18:48:25 -0400 Received: from mga05.intel.com ([192.55.52.43]:3986 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727503AbeJKWsY (ORCPT ); Thu, 11 Oct 2018 18:48:24 -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 fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2018 08:20:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,368,1534834800"; d="scan'208";a="78019102" Received: from 2b52.sc.intel.com ([143.183.136.147]) by fmsmga008.fm.intel.com with ESMTP; 11 Oct 2018 08:20:44 -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 , 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 Cc: Yu-cheng Yu Subject: [PATCH v5 08/27] x86/cet/shstk: Add Kconfig option for user-mode shadow stack Date: Thu, 11 Oct 2018 08:15:04 -0700 Message-Id: <20181011151523.27101-9-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181011151523.27101-1-yu-cheng.yu@intel.com> References: <20181011151523.27101-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 | 26 ++++++++++++++++++++++++++ arch/x86/Makefile | 7 +++++++ 2 files changed, 33 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 1a0be022f91d..5f73335b7a3a 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1913,6 +1913,32 @@ 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 ARCH_USES_HIGH_VMA_FLAGS + select X86_INTEL_CET + select ARCH_HAS_SHSTK + select VM_AREA_GUARD + ---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 8f6e7eb8ae9f..b28842b80295 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