Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2815920rwb; Thu, 29 Sep 2022 15:45:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5v7kVJpQDkAcjqo2rLV6P0INV8UNhFRqKVv9eu7JDWoCVS2qIbJcMOhtfeq31czVqm+ShY X-Received: by 2002:a17:906:730f:b0:783:27c5:f65f with SMTP id di15-20020a170906730f00b0078327c5f65fmr4555512ejc.142.1664491546050; Thu, 29 Sep 2022 15:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664491546; cv=none; d=google.com; s=arc-20160816; b=tMSt/xBsgQRnvcM/obGROnAQfsICTNYOIrOfMysMD+2eJcCdEWdgHTGw19SpA6CMpv ff/U7+vQgBxerinNQIS/BaT2qYfzP8qgr2LBTj0PLtc6pi4lGKYTz8XUr/DCmZHy0yjU R5tQCiAit0YluDAKAlCkoXUKiNSsQMCtnc58JqvRi3lNyLLD7qCvDRd3+O+fqDnkfSQ4 n8mv6/3FvXqvlS3l83lORP279ch4iJ+Zmk6pYXRlBCkSnmfa+e48zEe+tQf6eru+2RF3 +GVzV5yBdxah7yHFFAZ55Am1cQEr6JLBGLLJsgBjoHjWLhcW66k1oNsWnn5F+Lix8NX9 /iUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=zJrzKUJqqQt+ShwooMSXDPE4Q2qA9Kmom53Abesu9Fs=; b=nVVKR/pkOMhQkLziT6AAYfgXNKrYVQ2ZFVGuqizxcHpa3kp5CbLy3xxpsLi5YksftM 8GXAGYEweSkhxDaA7vGCzvlCF0ljGlFD/d7noBAZJR7w9nSs1331bKOnnOzv997UnxEf ZdPG2XtSECrsig1fQ4URo8FWJhN63frWsC+FQSDYUXsAOkclOkX0q0/ukeKYxsJOzQDw VHVcFWUTu0RALjsLD2AOlbVXT7myWTz/hcZIXvlsmswFaK06e0efkUEAy5HDlGQa9RXO BbOb8OnTC8zGL1lw7L4EogfZZv9MsioSyt0T/H9pfu/9orJ1QPrZN0Sg/90BvJPVkLaQ 5haw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AhWSwTYq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e25-20020aa7d7d9000000b00456ed5c909bsi613793eds.590.2022.09.29.15.45.20; Thu, 29 Sep 2022 15:45:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AhWSwTYq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229889AbiI2WaB (ORCPT + 99 others); Thu, 29 Sep 2022 18:30:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbiI2W3w (ORCPT ); Thu, 29 Sep 2022 18:29:52 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EB221DA54; Thu, 29 Sep 2022 15:29:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664490591; x=1696026591; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=LROLd1DXeI67ae2qnslC9c0J7dEIWigwReKeDsym990=; b=AhWSwTYqTOqyYX1KREMaB9YmyrMfcO3yYpwpF+4j+VlyL2Xkp0AXLjWJ TrU8r/sxWSO3OaYu4ne3eVRxWUgksL8Xj7+V/pXXIOTCMGu6+bwP/yNCo gmv5O64H/XswZE2FHdkmM4bW12bUar3eu8ASA8GfSA+JHOEdN3np+nGTa rPTrXBo0JdH7kqqXB3jTp5GPELDQ2VyXgvrlGaybQO5+PjEFBYd0DWb8o tC5XL0R+j8TDG09nTbTExMdPa+BH7/u8+jsTqn9H9UTJaIzo1XuspS4yf HFBx/VJjNFwrLkChl3M7otihnEwShmFsNje/HrgMKBccn+LtskDiXtAxB Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="303531320" X-IronPort-AV: E=Sophos;i="5.93,356,1654585200"; d="scan'208";a="303531320" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2022 15:29:50 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="691016074" X-IronPort-AV: E=Sophos;i="5.93,356,1654585200"; d="scan'208";a="691016074" Received: from sergungo-mobl.amr.corp.intel.com (HELO rpedgeco-desk.amr.corp.intel.com) ([10.251.25.88]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2022 15:29:48 -0700 From: Rick Edgecombe 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" , Weijiang Yang , "Kirill A . Shutemov" , joao.moreira@intel.com, John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com Cc: rick.p.edgecombe@intel.com, Yu-cheng Yu Subject: [PATCH v2 02/39] x86/cet/shstk: Add Kconfig option for Shadow Stack Date: Thu, 29 Sep 2022 15:28:59 -0700 Message-Id: <20220929222936.14584-3-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220929222936.14584-1-rick.p.edgecombe@intel.com> References: <20220929222936.14584-1-rick.p.edgecombe@intel.com> X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yu-cheng Yu Shadow Stack provides protection against function return address corruption. It is active when the processor supports it, the kernel has CONFIG_X86_SHADOW_STACK enabled, and the application is built for the feature. This is only implemented for the 64-bit kernel. When it is enabled, legacy non-Shadow Stack applications continue to work, but without protection. Signed-off-by: Yu-cheng Yu Co-developed-by: Rick Edgecombe Signed-off-by: Rick Edgecombe Cc: Kees Cook --- v2: - Remove already wrong kernel size increase info (tlgx) - Change prompt to remove "Intel" (tglx) - Update line about what CPUs are supported (Dave) Yu-cheng v25: - Remove X86_CET and use X86_SHADOW_STACK directly. Yu-cheng v24: - Update for the splitting X86_CET to X86_SHADOW_STACK and X86_IBT. arch/x86/Kconfig | 18 ++++++++++++++++++ arch/x86/Kconfig.assembler | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index f9920f1341c8..b68eb75887b8 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -26,6 +26,7 @@ config X86_64 depends on 64BIT # Options that are inherently 64-bit kernel only: select ARCH_HAS_GIGANTIC_PAGE + select ARCH_HAS_SHADOW_STACK select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 select ARCH_USE_CMPXCHG_LOCKREF select HAVE_ARCH_SOFT_DIRTY @@ -1936,6 +1937,23 @@ config X86_SGX If unsure, say N. +config ARCH_HAS_SHADOW_STACK + def_bool n + +config X86_SHADOW_STACK + prompt "X86 Shadow Stack" + def_bool n + depends on ARCH_HAS_SHADOW_STACK + select ARCH_USES_HIGH_VMA_FLAGS + help + Shadow Stack protection is a hardware feature that detects function + return address corruption. Today the kernel's support is limited to + virtualizing it in KVM guests. + + CPUs supporting shadow stacks were first released in 2020. + + If unsure, say N. + config EFI bool "EFI runtime service support" depends on ACPI diff --git a/arch/x86/Kconfig.assembler b/arch/x86/Kconfig.assembler index 26b8c08e2fc4..00c79dd93651 100644 --- a/arch/x86/Kconfig.assembler +++ b/arch/x86/Kconfig.assembler @@ -19,3 +19,8 @@ config AS_TPAUSE def_bool $(as-instr,tpause %ecx) help Supported by binutils >= 2.31.1 and LLVM integrated assembler >= V7 + +config AS_WRUSS + def_bool $(as-instr,wrussq %rax$(comma)(%rbx)) + help + Supported by binutils >= 2.31 and LLVM integrated assembler -- 2.17.1