Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp782747imm; Fri, 21 Sep 2018 08:13:19 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Hkr8VY+TqullJSyAKRRZB5lgZ7GB8lG3fsKo5QlfiwCTIVUwQKUeHjnddMHRnmOjZgUJA X-Received: by 2002:a17:902:7604:: with SMTP id k4-v6mr2902253pll.170.1537542799845; Fri, 21 Sep 2018 08:13:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537542799; cv=none; d=google.com; s=arc-20160816; b=wY4AWgLb8aefTTGP3xpH2jNqfCBpLBPHKKK0tBu+QfJ5+lH5591kvVT7q+nojGwGVz MJumCaE6JHrTla6mJ8lvfbYZLfQv8YFyk5ax9rf8VHuufPtYPrGOOtNa+Jd7Hnlb/Y6D FoaePfUUVQaG4arvQrivVBmxwXRDCFSohznY4NXjMTYzTR45XXwSaMasjIEJp/XQjcA0 6EC3NhS9yJf4Syde8KaGIrWFBJtRjid0iU9Ahfwa+7R1oP0l8w3PYtysnKZ2kvO10QXu 7UliijHnxuIN4tppq+tMh7mqK2LRsV7wfSjCcXZd0gnFydbKHC9qdxbLqJGWB2kB1GLp z2mQ== 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=SrAoz3B3fVnohd0Wm1rBW1k5UQJ9ZmOZzebnbQuoFhw=; b=rzICUzO7OqUXHrzr5Mx5WSTCnZvSUf3N/Pfe+iR5VbKzf+xAQhPY2wKXRtIRPTkEX1 jpfZpNBZrxXLKys12KFEFAV+vAHitpYxmHRnFuHXrL0a7WG2MxXa5pvAHMFRC1IsVv9X H17eu9DzDjgk3b9lS61HZGopyAS+4BXNAKdqfQPqNo8+KCXj7juEbEMuLHC4KnnHZeRU 451myYPaBtQxOw2b9TmrYwzpP5SyyBKSWC10rt/ng7YCTu7lYZAjI7me7YWFUhTOG2Vv 5N+kriTEZuq/Ck9B3V7x6drPMq8SLrZxaOgf7d7q16okShOK3m63X/hbjVUpvuz/5w59 jr3g== 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-v6si29225853pfd.273.2018.09.21.08.13.02; Fri, 21 Sep 2018 08:13:19 -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 S2390744AbeIUU7e (ORCPT + 99 others); Fri, 21 Sep 2018 16:59:34 -0400 Received: from mga06.intel.com ([134.134.136.31]:22409 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390389AbeIUU6I (ORCPT ); Fri, 21 Sep 2018 16:58:08 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Sep 2018 08:08:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,285,1534834800"; d="scan'208";a="71856549" Received: from 2b52.sc.intel.com ([143.183.136.51]) by fmsmga007.fm.intel.com with ESMTP; 21 Sep 2018 08:08:48 -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 , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue Cc: Yu-cheng Yu Subject: [RFC PATCH v4 07/27] x86/cet/shstk: Add Kconfig option for user-mode shadow stack Date: Fri, 21 Sep 2018 08:03:31 -0700 Message-Id: <20180921150351.20898-8-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921150351.20898-1-yu-cheng.yu@intel.com> References: <20180921150351.20898-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 1a0be022f91d..808aa3aecf3c 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 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