From patchwork Thu Jun 7 14:36:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu-cheng Yu X-Patchwork-Id: 10452265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 934F660375 for ; Thu, 7 Jun 2018 14:40:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B66D2963B for ; Thu, 7 Jun 2018 14:40:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78A3729646; Thu, 7 Jun 2018 14:40:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A9D029648 for ; Thu, 7 Jun 2018 14:40:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 046576B0269; Thu, 7 Jun 2018 10:40:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 01F6D6B026B; Thu, 7 Jun 2018 10:40:42 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDACA6B026E; Thu, 7 Jun 2018 10:40:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f72.google.com (mail-pg0-f72.google.com [74.125.83.72]) by kanga.kvack.org (Postfix) with ESMTP id 827746B0269 for ; Thu, 7 Jun 2018 10:40:42 -0400 (EDT) Received: by mail-pg0-f72.google.com with SMTP id j13-v6so3573517pgp.16 for ; Thu, 07 Jun 2018 07:40:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=VLjOogQqx7Le3wRY1NuhB/B3Mf+yuaKssm8+KYVz/os=; b=UR7CiyMHbHLTjtjDPL0NDeYH3PgtL21ufKsI4VwKAhNEd9jbDY+bYEOl40cOUZSRtT RRTN+8vUqrQ90CS5jgvSdmBBYbSTwm2c9xs+0R8scB3vkcmzsly9J1mJhTRbBEsuxQ64 bp7iEHlYyvwqUUHwyXEJWdKtpNmpY5BVH9g6PiuS6P+iMU21CiJ71RxBMb19SUUMxa5V 7QjU5/fQRaeQ9720oGFESU3rRK+chiO1yg/8Mh46nz2ZqqOz6mV0HV2p0stgJyvBznB2 5JEBGvhwrykbW7cIqvZU448D2McRmwvyOpkb2SQZxI40v/zrMRMK/5S7YXIUNRE7g7GT RhEQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APt69E3VRGuWsDzGNuhB0TDA5A0bYwCav90B9HSLCs4w5zf80iOIGajO H2AVNivCs8T3gXGcevajhmLQzXkxi9W1xjrvVPL6UM8nUQdLBOuXekN5GvJ6im9qDBHQo2rgvA6 yNFWwe/phK1aA9dgt2dZNXk1n7dqh9TC2eY0fnSZqsboGNRAGR54q/7vkJ+VarFOTdQ== X-Received: by 2002:a62:b201:: with SMTP id x1-v6mr2055621pfe.189.1528382442205; Thu, 07 Jun 2018 07:40:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLRbYeG8WPdx8qx2TjHbnn5W5QvdQCzoyq3UoN3MC8spvQ5ipeYkzD3ChWhGOPlHQ8bOQKz X-Received: by 2002:a62:b201:: with SMTP id x1-v6mr2055587pfe.189.1528382441469; Thu, 07 Jun 2018 07:40:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528382441; cv=none; d=google.com; s=arc-20160816; b=bYx+b1LdImRLysPftcU9oLhUrSQY0t1BFjApkSoEAUfeRNicMae3gojf5JSOLPot6X zo5auAVJbxxvXAgUODFYXXfqizdSjBXUp62pdPF+VWJOtJUEQHTKEezfuQb9e9wMBq26 Esd0Qm6p1lj/7f+X42FH8DM1kMtIa5ysz8sg1LReALPe//LHLZuWn0Sk26xIacuyNvti hEIudDzp4BeNjH6tOOzNTlRQVhvEg9zBd25KER7BFUteZVKsSvoWDIWYInP7KR+J9QXV 9zfcKxi6w8D3EjfQQoxuIh+ZL+qPEu+hk85pUTdyYSL9P4NpOl8cFJF/ul6xs/NVMhtP nG8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=VLjOogQqx7Le3wRY1NuhB/B3Mf+yuaKssm8+KYVz/os=; b=tx7A1UaiagLGAtpb+/Z0zv4kmuhAKP4E8ScrVypAw8HzE1EPPD0ki6YCIKaYR1wJoS rSmKuRYwE1O3I8aCixECmyufV87SoxQnkk3KvlngaMPwCJDch3iETKRiH7NvFHi2kMf1 hwLpYuVkLLjfnOqy6diOzhqqeH5Bgz5UnDMHazow4DLOFv0h/k9vTjIqla0c4PIH852R knjFiTTKdwwKzcaTkPdXdg5Ifa+rqtv4lDXOD1UmIUVm0T2i7BTkX8L4FDSdVNXuyF9h vA5zEcff0Q4J31vjBwQ+JRl0HmgV8UjEshupNqaLjwaCI+I5yHoRc/G0Yub0QPNpU0Ms J9ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga18.intel.com (mga18.intel.com. [134.134.136.126]) by mx.google.com with ESMTPS id b60-v6si54342625plc.270.2018.06.07.07.40.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 07:40:41 -0700 (PDT) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.126 as permitted sender) client-ip=134.134.136.126; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2018 07:40:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,486,1520924400"; d="scan'208";a="47542289" Received: from 2b52.sc.intel.com ([143.183.136.51]) by orsmga008.jf.intel.com with ESMTP; 07 Jun 2018 07:40:31 -0700 From: Yu-cheng Yu To: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , "H.J. Lu" , Vedvyas Shanbhogue , "Ravi V. Shankar" , Dave Hansen , Andy Lutomirski , Jonathan Corbet , Oleg Nesterov , Arnd Bergmann , Mike Kravetz Cc: Yu-cheng Yu Subject: [PATCH 2/9] x86/cet: Add Kconfig option for user-mode shadow stack Date: Thu, 7 Jun 2018 07:36:58 -0700 Message-Id: <20180607143705.3531-3-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180607143705.3531-1-yu-cheng.yu@intel.com> References: <20180607143705.3531-1-yu-cheng.yu@intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index c07f492b871a..dd580d4910fc 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1925,6 +1925,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