Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp849900pxv; Thu, 22 Jul 2021 13:59:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrnQ1boqcAU2zxVFy5y/2n3rzptYaNK/2db3dS5Oyoyau0LHb0nfUnt3USsTB957KSbyOb X-Received: by 2002:a92:ab0a:: with SMTP id v10mr1174473ilh.17.1626987588718; Thu, 22 Jul 2021 13:59:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626987588; cv=none; d=google.com; s=arc-20160816; b=KTC7wQP+N3Ng2pfxhXB4yEQbvQgIN+565g9IaXYiZqnw2532DzpoaVuGdqLRdvM/zT J3nRPWd0NcYemuD2TCve6X+JwvhmD9CQgh0sVXzMwlX0PuHAvhXQHqrdrzmUzckQu2Rm 6OOGCmqxTe1f9sSGxulYD7PMAO3nmdW6NXFQHJEbu2c16Iv1kyO8QWIKPkyLa7mqaYAu faXm1SeThp5axd0tnFmZJ9jczOuF43meuJkRzvJX+Qb6LIB0fQmNgzQcaRz16v+cZSD4 QN1pXRTvwjlZBUEY4s+B3RepydU20V80YznpnRgvlNwsxC7jS6Fvjhqr4fA/lFoqPZue sgZw== 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; bh=o841Qwc/V4yhV7ORYkfPKjLRaAnVzq06uO+5szuAnFE=; b=WbtO3swFAv+yEfrzEL06Q8unnxCE/6SQUOnWvKvvq3AaRixjFre3160YF58G/kXmpK GQG2WKHHI58u1G4eimwj0eHEFbrmRGO7O1c+aiBHrnWT23kJZRIPKT/i49N4GOpnCDJC AAhOOnvTsKer2ypWI5dImdaHI11ya3QLFCC+qDi/XsSYZKqhpCALYOy07yw0Sz+O2MUf DzpiZ6NiqpkSsYudEC/Mhw3zPzrWPDCJn8hGqyx2hKIR20GPIik989p1Fql3C11b4elx nI6hUZrmhliM4+2rU/N2wMrZyWJrFM+j7z1tmcy8My59AzkXwwVDLjpkJXsR6OHQHG7q u4tA== 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 d187si34325730iog.56.2021.07.22.13.59.37; Thu, 22 Jul 2021 13:59:48 -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 S231487AbhGVURi (ORCPT + 99 others); Thu, 22 Jul 2021 16:17:38 -0400 Received: from mga03.intel.com ([134.134.136.65]:15252 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231162AbhGVURa (ORCPT ); Thu, 22 Jul 2021 16:17:30 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10053"; a="211800510" X-IronPort-AV: E=Sophos;i="5.84,262,1620716400"; d="scan'208";a="211800510" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2021 13:58:03 -0700 X-IronPort-AV: E=Sophos;i="5.84,262,1620716400"; d="scan'208";a="433273358" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2021 13:58:03 -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" , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang , Rick P Edgecombe Cc: Yu-cheng Yu Subject: [PATCH v28 01/10] x86/cet/ibt: Add Kconfig option for Indirect Branch Tracking Date: Thu, 22 Jul 2021 13:57:14 -0700 Message-Id: <20210722205723.9476-2-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210722205723.9476-1-yu-cheng.yu@intel.com> References: <20210722205723.9476-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 Reviewed-by: Kees Cook --- 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 7a2991457497..8f0bba206206 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1933,6 +1933,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 b7728f7afb2b..e3a08fcd72f4 100644 --- a/arch/x86/include/asm/disabled-features.h +++ b/arch/x86/include/asm/disabled-features.h @@ -71,6 +71,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 */ @@ -93,7 +99,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