Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2212546imm; Tue, 10 Jul 2018 15:34:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe+HUnAjNDFRlXvMW6C59vgPbR3ruo5xTXa7nriyjf12tyRsGiXzx0GS4o0KKLJqpAPKpKE X-Received: by 2002:a63:2a0b:: with SMTP id q11-v6mr17531151pgq.36.1531262089691; Tue, 10 Jul 2018 15:34:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531262089; cv=none; d=google.com; s=arc-20160816; b=YWmVoTEURBl/K6OTEUyG1HOw2A5TTF6nYvnlQIOvPv6udyFzFdFzeZV1+HSvm5Z3sv Uz7mkaOwJ0MN0HocTffgqqVnPDzyQs23QLKQLfmnGp0+LmS24PqM/QMToX19To8NYR7n RIM86QbeKhIYmzL98zZh1blMkz6ojZqkFy7pWkf+rYBrUbr+wpvQ0D2SDjdt+YgPMu+T QiLX8tf581x5afpKvaF00u9lYZj9Qg026oSDmc92Whxti8VUdEM0pAv+en02DhI7JFTq p8J/mdK/IeMcVOSaRZ7GL7JuFEjTYVLWbgGJH94QuR4kPL1w0RQfxyAbkz1SOySmAvb1 kwag== 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=pw6se1aGC/J5C9lGb7l2IqvbhF5S3W91ECTKFGwdCIk=; b=j/lHlZ6/9TyXMH3SJHts13B55WobJ7Bc4248aA+Yw/TOQ0HAdxiOYCJOTWg0r9LqGg 8PYJM/HNt4EO21xzhtDsK+S7A2AI2qIMM7Yf9t5CP39m/8O9ibb6kWx50f7l9k9f/Umy fqZznYe68t5k+WpjIj6nKZRR3tLRagCR6UHBybDaZ9Znjku4gpZsOCtt+78niGrt+y7C 9agD/iH+8trLVjZEuNlMsEk5bObIPmE+Fj/wOYwjUWAlSMu5HbX7uGXSwydPxXkOCKWU bpRFcgDA+pgpu5ZYVVSRDbCBhh4O98WjJ2MgKDeAZC50oVd9RVg3zPMdaTLj3zLMeRIZ 9TXQ== 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 f23-v6si19446286plj.494.2018.07.10.15.34.34; Tue, 10 Jul 2018 15:34:49 -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 S1732580AbeGJWeb (ORCPT + 99 others); Tue, 10 Jul 2018 18:34:31 -0400 Received: from mga02.intel.com ([134.134.136.20]:63054 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732309AbeGJWcX (ORCPT ); Tue, 10 Jul 2018 18:32:23 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2018 15:31:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,335,1526367600"; d="scan'208";a="70305384" Received: from 2b52.sc.intel.com ([143.183.136.52]) by fmsmga004.fm.intel.com with ESMTP; 10 Jul 2018 15:31:11 -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 v2 07/27] x86/cet/shstk: Add Kconfig option for user-mode shadow stack Date: Tue, 10 Jul 2018 15:26:19 -0700 Message-Id: <20180710222639.8241-8-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180710222639.8241-1-yu-cheng.yu@intel.com> References: <20180710222639.8241-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 f1dbb4ee19d7..44af5e1aaa4a 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1917,6 +1917,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 a08e82856563..ad1314e5ef65 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -157,6 +157,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