Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4069858pxu; Mon, 12 Oct 2020 08:44:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydDrYXSXvFoRTMFp08fP+mUdu6hga1faHXupbpDOnnEJQ9ipm9Tc5cR+n+6XTPEbdW7tv3 X-Received: by 2002:a50:9ec6:: with SMTP id a64mr14792691edf.382.1602517442437; Mon, 12 Oct 2020 08:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602517442; cv=none; d=google.com; s=arc-20160816; b=eUkHAc3j7M4lstmSHPbZ2j6rKG2DfMxuH/pcbOSMLe9J3h4OU0b2RfOxl0xZMDWWQS PTActL84CJPQxGwj3Ef1pYLbjcclrlnxJhNemuLN4ISlz3S+HZBrcW6eoiJCuB7x503A bYM7JTxXfL6PoW1lGEnUfzYO3pO2bZmri5bfHgUzF3Idl3Jiwzbz1va8e+jJ8z2d7gbG oTgoW8QIKNkCcrf0/2luIt5IxcINGNLacRa1K3lW0ERsJiE7k+eoE/JosBcTOHINGHgF a/xu1IFpkKi+2II01Hv9qQO9AmkabqtFaI0PFfRnqVCfPBwRBFbk8ZAS5J3yBjaSvhyO cimQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=P+pjUf5lendGh0veRvJhpfObMuq9ANVsfXW+d/4n7GA=; b=dAG/vgrYHyQKmlR/lANbPDaTWJc3yLCOyAV/q7FAqPIdByo765vnUWzAriBE54t8h8 IBnp1F8rrAUak19FBGnJn1F6bZYVx5z2xbnnzXIet4jDmjGB/HESztoGxYulmid/4RiD zbUWmihGI9EzplykpoTGFurFbDEp2eA2ltqX+/kMFTw9MpKoTd7UTIjtdSz1kN43glg1 b1/hkaP+6n/1Wdxy6kjn5c2GMYFkSvxBh4rO5Orhu8MsmNL4MO/Fx47H2rkRCMly/61A 2PaygNb4nJiDqhtIT1QEZdvwXefbvIbmcF12r85RGTWkgNOoHJEHATlmx1WCQAhyEIoU zI/g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 r27si12799974edw.277.2020.10.12.08.43.39; Mon, 12 Oct 2020 08:44:02 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390901AbgJLPl4 (ORCPT + 99 others); Mon, 12 Oct 2020 11:41:56 -0400 Received: from mga05.intel.com ([192.55.52.43]:1318 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390220AbgJLPjr (ORCPT ); Mon, 12 Oct 2020 11:39:47 -0400 IronPort-SDR: rB/dfEAD2OBn7L/NJKsIqzq1+X0ehYd7Hzno0I1I2kz8P2hannpW1FpGbBTekPiZDQTX/RFovA H2aIVnvSbukw== X-IronPort-AV: E=McAfee;i="6000,8403,9772"; a="250452647" X-IronPort-AV: E=Sophos;i="5.77,367,1596524400"; d="scan'208";a="250452647" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2020 08:39:47 -0700 IronPort-SDR: XTgCTCRrOZkmSn0c3bXb4zJ4RXcMepdbQrrrDrHfEcfquQYRVBjdPFphL9fcZ/ezjI83o27hgX hK1HidnIVlzw== X-IronPort-AV: E=Sophos;i="5.77,367,1596524400"; d="scan'208";a="530010785" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2020 08:39:46 -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 , Weijiang Yang , Pengfei Xu Cc: Yu-cheng Yu Subject: [PATCH v14 05/26] x86/cet/shstk: Add Kconfig option for user-mode Shadow Stack Date: Mon, 12 Oct 2020 08:38:29 -0700 Message-Id: <20201012153850.26996-6-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20201012153850.26996-1-yu-cheng.yu@intel.com> References: <20201012153850.26996-1-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Shadow Stack provides protection against function return address corruption. It is active when the processor supports it, the kernel has CONFIG_X86_SHADOW_STACK_USER, 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 --- arch/x86/Kconfig | 33 +++++++++++++++++++++++++++ scripts/as-x86_64-has-shadow-stack.sh | 4 ++++ 2 files changed, 37 insertions(+) create mode 100755 scripts/as-x86_64-has-shadow-stack.sh diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 7101ac64bb20..415fcc869afc 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1927,6 +1927,39 @@ config X86_INTEL_TSX_MODE_AUTO side channel attacks- equals the tsx=auto command line parameter. endchoice +config AS_HAS_SHADOW_STACK + def_bool $(success,$(srctree)/scripts/as-x86_64-has-shadow-stack.sh $(CC)) + help + Test the assembler for shadow stack instructions. + +config X86_CET + def_bool n + +config ARCH_HAS_SHADOW_STACK + def_bool n + +config X86_SHADOW_STACK_USER + prompt "Intel Shadow Stacks for user-mode" + def_bool n + depends on CPU_SUP_INTEL && X86_64 + depends on AS_HAS_SHADOW_STACK + select ARCH_USES_HIGH_VMA_FLAGS + select X86_CET + select ARCH_HAS_SHADOW_STACK + help + Shadow Stacks provides protection against program stack + corruption. It's a hardware feature. This only matters + if you have the right hardware. It's a security hardening + feature and apps must be enabled to use it. You get no + protection "for free" on old userspace. The hardware can + support user and kernel, but this option is for user space + only. + Support for this feature is only known to be present on + processors released in 2020 or later. CET features are also + known to increase kernel text size by 3.7 KB. + + If unsure, say N. + config EFI bool "EFI runtime service support" depends on ACPI diff --git a/scripts/as-x86_64-has-shadow-stack.sh b/scripts/as-x86_64-has-shadow-stack.sh new file mode 100755 index 000000000000..fac1d363a1b8 --- /dev/null +++ b/scripts/as-x86_64-has-shadow-stack.sh @@ -0,0 +1,4 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +echo "wrussq %rax, (%rbx)" | $* -x assembler -c - -- 2.21.0