Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4833530pxy; Tue, 27 Apr 2021 13:49:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1VeoIIPmMykwL04TsorZgGteA5m5axum1he7n6zWsloibpXRcibxSDs9jS9Pa18YxfOu/ X-Received: by 2002:aa7:c454:: with SMTP id n20mr6906848edr.138.1619556570238; Tue, 27 Apr 2021 13:49:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619556570; cv=none; d=google.com; s=arc-20160816; b=IKuTwaHCSIlU0XSzLW4KzrojH4t1prv7Hb0VwNrnIaozlx82V5i1czAbCgXoMkkaqT SOnwdOLRx0Oj3pAn2cWr2dobi8FmpL6oCepaXUfSEqajvb33fa+RUyxYdGhAWQdOopt5 PJKVa78LiAxOLE0xDc6A+CzwuiHEdY2YF/mySc2OliGrTszccQUH+G1opfUUdc/rNvGp jwhxWTVHuQuYYWrJEaLGlCN1t05aLuh5zINw6AQN/NqO2lGEf65FFiqfI3M4AsMpruLq DaoO2MO7B9iVd0ZwjkfJgWf6ztokk+cplAL29Qu3h2dEwNVTID9OlbBEoMXlWgqR+xNW iIJg== 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=iEp3vMC7DUjkiKG3QIxOblrj03U6SLQ9Ew3WqRdCJGI=; b=yVTRdMUCSn5+QSpuc4rToKH1Bg5Q7Uh4AfcdDKsbamoA6TISkdXqDZLDuBQKc3zcZV SnWqK2eRU/o/7tBEkvRRPC1rAtjqSvJ5Y5dyww2xNmeSCr3ibhcjE6Bh/AMu9JZ9vIpx ti5193/0H4b7j//ZdffsUBNGlvl76RCE85GeFgAsJ/4dMeFdpvwS0mOaCbsmXlYoO8ne ArCvdkrihxX1PCCxvtp9jfYygop+ktaL/irsI2REdelBMmeWwL6y0ueAxderuUX3TNh9 RXbOXizVwEgkYEe+WJKNEO5Or8IUM3VcHHKAJ9fUY4ie5QRD8oagvbQG5TfIZy2cuo09 F9uA== 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 sb9si924120ejb.615.2021.04.27.13.49.05; Tue, 27 Apr 2021 13:49:30 -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 S239112AbhD0Usp (ORCPT + 99 others); Tue, 27 Apr 2021 16:48:45 -0400 Received: from mga09.intel.com ([134.134.136.24]:56332 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239118AbhD0Usc (ORCPT ); Tue, 27 Apr 2021 16:48:32 -0400 IronPort-SDR: KG8Ae6puePo12Ee8xNlYUz8KO7wkmz+KTF9GSP9scNrFfRF1Sk+bg3sOGF9YiksmepJ6p/dxYH mQ/OAVhlKtBw== X-IronPort-AV: E=McAfee;i="6200,9189,9967"; a="196699375" X-IronPort-AV: E=Sophos;i="5.82,255,1613462400"; d="scan'208";a="196699375" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2021 13:47:46 -0700 IronPort-SDR: 6nLYEAddouy36fNcM0WDDZlcvPnFj1T2XiWHGrMlEJ6tIvvXlqCkSb67R4dFwjPSnMNQ17B8tF harbdUpW1VOQ== X-IronPort-AV: E=Sophos;i="5.82,255,1613462400"; d="scan'208";a="457835072" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2021 13:47: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 , Haitao Huang Cc: Yu-cheng Yu Subject: [PATCH v26 1/9] x86/cet/ibt: Add Kconfig option for Indirect Branch Tracking Date: Tue, 27 Apr 2021 13:47:12 -0700 Message-Id: <20210427204720.25007-2-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210427204720.25007-1-yu-cheng.yu@intel.com> References: <20210427204720.25007-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 Indirect Branch Tracking (IBT) provides protection against CALL-/JMP- oriented programming attacks. It is active when the kernel has this feature enabled, and the processor and the application support it. When this feature is enabled, legacy non-IBT applications continue to work, but without IBT protection. Signed-off-by: Yu-cheng Yu Cc: Kees Cook --- v25: - Make CONFIG_X86_IBT depend on CONFIG_X86_SHADOW_STACK. arch/x86/Kconfig | 19 +++++++++++++++++++ arch/x86/include/asm/disabled-features.h | 8 +++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 77d2e44995d7..6bb69fba0dad 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1965,6 +1965,25 @@ config X86_SHADOW_STACK If unsure, say N. +config X86_IBT + prompt "Intel Indirect Branch Tracking" + def_bool n + depends on X86_SHADOW_STACK + depends on $(cc-option,-fcf-protection) + help + Indirect Branch Tracking (IBT) provides protection against + CALL-/JMP-oriented programming attacks. It is active when + the kernel has this feature enabled, and the processor and + the application support it. When this feature is enabled, + legacy non-IBT applications continue to work, but without + IBT protection. + 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/include/asm/disabled-features.h b/arch/x86/include/asm/disabled-features.h index e5c6ed9373e8..07cc40d49947 100644 --- a/arch/x86/include/asm/disabled-features.h +++ b/arch/x86/include/asm/disabled-features.h @@ -74,6 +74,12 @@ #define DISABLE_SHSTK (1 << (X86_FEATURE_SHSTK & 31)) #endif +#ifdef CONFIG_X86_IBT +#define DISABLE_IBT 0 +#else +#define DISABLE_IBT (1 << (X86_FEATURE_IBT & 31)) +#endif + /* * Make sure to add features to the correct mask */ @@ -96,7 +102,7 @@ #define DISABLED_MASK16 (DISABLE_PKU|DISABLE_OSPKE|DISABLE_LA57|DISABLE_UMIP| \ DISABLE_ENQCMD|DISABLE_SHSTK) #define DISABLED_MASK17 0 -#define DISABLED_MASK18 0 +#define DISABLED_MASK18 (DISABLE_IBT) #define DISABLED_MASK19 0 #define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20) -- 2.21.0