Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1516584ybl; Tue, 13 Aug 2019 14:07:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwg1lRaDe+rCfylzIB1ZJ1X6f5c3ZQVuXXvLol1X7FECLeCWNRVBPB+V9Pfzxp057it7GuE X-Received: by 2002:a17:90a:b011:: with SMTP id x17mr4033730pjq.113.1565730456270; Tue, 13 Aug 2019 14:07:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565730456; cv=none; d=google.com; s=arc-20160816; b=iKuolDv0bHu9Zs3qG1B3bYf5v103ggkLAOKKyeW6/mNo5Pl4FL0gclakakXojiKAyh bDQnAJvVl6z62SpxcAwY7C4YWsWebXrXcDJd0Zv8M7vzFBR+lzp0W6FWi1PsvFyytsnT XFGyAOrAGChO+GYTA6Vux9uaPpbmClryq2lquazmNhiowvFNomxC57y6m4oBo5M/i4Y7 +6zlOs28Owdfepl0lW4VR0i9xmEQ/lfA9reESsQWdNsM8Uwx8f5mY4Yx9exqGeMCjvmR hnnDwsFq2Uqvkx7d4GcUVUt9Iy+EBREMCEDrwUfXbmuEToMAO+0k4YTQ3r88Dwg+lHgy cUWQ== 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=NmupN2y4tfRlNEkfEqA5LW075akOmrJ8oF6d0lzcK0Q=; b=oDs5dJUyosM+wfarL+JGlJKFOD2q0btrES+zS4nrxFNAZx7loqIfL93gxNSXYU58Hb XotSAEv+GUUDhX9gdOLQv4bllHuMKTZx2mm00HqnXDGvEs2iAR4w3kvh0sOxXEdkNIjQ IGQ62oIZBYzZNkOUneW2GhObA+sViHWJddcATLzwCdeLc2QS5SbymkTb3Lp5JtBl566b N8sFjiEVjdOnY1HxW6lx8Gl9Qtoy5zBpHLBNoPeeOwaMOkQgpbkXQfMh6Qdx0F1VFoUG /Uc4ByeK5hkaC6tvr5XJ8eRJEYEj7x04RBpWkAyU3BpALitmIVY/EmrHwIFDVisG9N3v 2Eqg== 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 t4si3748410plb.366.2019.08.13.14.07.20; Tue, 13 Aug 2019 14:07:36 -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 S1727327AbfHMVFz (ORCPT + 99 others); Tue, 13 Aug 2019 17:05:55 -0400 Received: from mga06.intel.com ([134.134.136.31]:16057 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726560AbfHMVCm (ORCPT ); Tue, 13 Aug 2019 17:02:42 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Aug 2019 14:02:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,382,1559545200"; d="scan'208";a="187901353" Received: from yyu32-desk1.sc.intel.com ([10.144.153.205]) by orsmga002.jf.intel.com with ESMTP; 13 Aug 2019 14:02: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 , 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 Cc: Yu-cheng Yu Subject: [PATCH v8 07/27] x86/cet/shstk: Add Kconfig option for user-mode shadow stack Date: Tue, 13 Aug 2019 13:52:05 -0700 Message-Id: <20190813205225.12032-8-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190813205225.12032-1-yu-cheng.yu@intel.com> References: <20190813205225.12032-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 | 25 +++++++++++++++++++++++++ arch/x86/Makefile | 7 +++++++ 2 files changed, 32 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 222855cc0158..eaf86ef13348 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1934,6 +1934,31 @@ 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 + ---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 56e748a7679f..0b2e9df48907 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -148,6 +148,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