Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp619418pxb; Tue, 1 Feb 2022 07:07:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyikB6Ycl8gQnSHL5GB+oITELXinM58YjvghJ+3e0TJnjNDiwqt4rcQ8XKSywK/fjKbaRAS X-Received: by 2002:a50:fb09:: with SMTP id d9mr6697805edq.391.1643728070548; Tue, 01 Feb 2022 07:07:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643728070; cv=none; d=google.com; s=arc-20160816; b=xwg4FSbxurA6/vCCsJtlyx2OYwdcF7OleuC0ZrvxaNuwVCvS+13ZvMJMRhFyA+lbkI bM1oKXy83f7SGrIGMDXvb1j7I4pH9XUxVCxlwZRc4vlPHx8GtWl/0K4f9f1DrtdawIOh r3qzuITLVObIThr5jlkUj59LwT4RMZSErn5v6w8Lgp4Kv7MCNvOoJDrwdRpwkP7UsJ7F 1kUNdvnGfXouFjzW3/dbI+a+PRKr1MMD8Bo4lJSR48llh6Ej1dEh98cJXeL93O6HTlT2 tVYMfuQ5AWBllJyHmzMjNbetjxwKJmcy11T3QzyP9LgOPltBcX3gjmDnqyyWyleuyUMk C4kg== 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=a/f7abpiO6ITKEg0Tzqd6COEV9X2obvuJ+6g/Sv9DDI=; b=KVM/RUfPKsJU4KiOpbbSD0PBT7annoSmZedx143nlFtC8/5VPVqYIoPfIP/qhtwym5 0VNuEl2+aGwziIc5SAKtSLwCILweC8u0ToWiUvYrlNEUWG8obWclJGp893US2VEYYqn3 fy3DpREkGs4byPVIrCH/Zmci7dbAeE01rPKqkHledcSwDtzXsPyfgHZA12D6NociE/mN kyRkWA/h4CVScKH6hh3CjSUd+Mna7xTbPvWPEaBv2M3kjg0XlEe5ZNGZu7WMe84xIogu eZIMw0c4xLqEM3XLqkPJzFrCu2AhY3a2pQcdX7ZsR7fZ/EiAENgGIFtkJABZYj7sXnaK J6SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EE4FOPZ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ji7si9374396ejc.39.2022.02.01.07.07.24; Tue, 01 Feb 2022 07:07:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EE4FOPZ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1356494AbiA3VV6 (ORCPT + 99 others); Sun, 30 Jan 2022 16:21:58 -0500 Received: from mga06.intel.com ([134.134.136.31]:52019 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356435AbiA3VVs (ORCPT ); Sun, 30 Jan 2022 16:21:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643577708; x=1675113708; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=yVxcklgB+ujIk3vYuj3CfwXGAGbbQ9OQA7BkA48dRkw=; b=EE4FOPZ6MyOUKgSCT9N1gOYNju0Ia0SdiXujh9Z6zpbsmMfSFSI3RzKN V2t9FdAEMUoF/yi1lbw0IgtvJivVkfUDK3+FQyFt71YWrwhvk5zwqi31t jaXlZn7AJMNxXNlqzBsFWbrUt1CftmHMAl0BzcklWajPoN7Dzhhgkatiw ghX1A2IJA3TQ4RJO8EFJfH+pXNgbPJFNtQgUUrJMLr2ckz263ByY0GLfg Rzc7DmsJyGZl296mUsXUVBuXghC6+tBABpLeS4A+/fyoSgSUhspoOWSaP WHeXxRM4C0jHlKUs21uPpWDiWMm1JAv6vTh5ia7AZuYROisYm6xL+jwhR g==; X-IronPort-AV: E=McAfee;i="6200,9189,10243"; a="308104879" X-IronPort-AV: E=Sophos;i="5.88,329,1635231600"; d="scan'208";a="308104879" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2022 13:21:48 -0800 X-IronPort-AV: E=Sophos;i="5.88,329,1635231600"; d="scan'208";a="536856661" Received: from avmallar-mobl1.amr.corp.intel.com (HELO rpedgeco-desk.amr.corp.intel.com) ([10.209.123.171]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2022 13:21:47 -0800 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" , Dave Martin , Weijiang Yang , "Kirill A . Shutemov" , joao.moreira@intel.com, John Allen , kcc@google.com, eranian@google.com Cc: rick.p.edgecombe@intel.com, Yu-cheng Yu Subject: [PATCH 02/35] x86/cet/shstk: Add Kconfig option for Shadow Stack Date: Sun, 30 Jan 2022 13:18:05 -0800 Message-Id: <20220130211838.8382-3-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220130211838.8382-1-rick.p.edgecombe@intel.com> References: <20220130211838.8382-1-rick.p.edgecombe@intel.com> 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 Signed-off-by: Rick Edgecombe Cc: Kees Cook --- 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 | 22 ++++++++++++++++++++++ arch/x86/Kconfig.assembler | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index ebe8fc76949a..b9efa0fd906d 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 @@ -1940,6 +1941,27 @@ config X86_SGX If unsure, say N. +config ARCH_HAS_SHADOW_STACK + def_bool n + +config X86_SHADOW_STACK + prompt "Intel Shadow Stack" + def_bool n + depends on AS_WRUSS + 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. This helps mitigate ROP attacks. + Applications must be enabled to use it, and old userspace does not + get protection "for free". + Support for this feature is present on Tiger Lake family of + processors released in 2020 or later. Enabling this feature + increases kernel text size by 3.7 KB. + See Documentation/x86/intel_cet.rst for more information. + + 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