From nobody Mon Jun 22 18:08:18 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75206C433EF for ; Fri, 18 Mar 2022 23:09:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241471AbiCRXKW (ORCPT ); Fri, 18 Mar 2022 19:10:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241433AbiCRXKU (ORCPT ); Fri, 18 Mar 2022 19:10:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32179F47EA for ; Fri, 18 Mar 2022 16:08:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A5928615DE for ; Fri, 18 Mar 2022 23:08:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7958DC340E8; Fri, 18 Mar 2022 23:08:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647644936; bh=+Gr67379WVWBWHw2ybHUFLROVBWIzwE3VSkuwwrlIuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fxU5nerOYn+YVqvuq87g+2P5UNUhrvDTJf0l/G6D6cq/fOie6DZIaCKcFhmvvN53t TgDwejuZeS8YL0DWUVGPjaYHpbUU7cSyNc/4haUxLkAG8KVj3Y6ONK0NumuHM+uvxG WgCtrs2DGbm5inrsqXO6v/kJlLtXnPNY0Ob1+XDQzbBRI78s3Ua7dLrzjwZ2Jcal8u y/oUJ1GxZx5MJ6ibMfUwLQh2w+zoKDP1pbOVdfYUsLCh8NS1ly/1a8PcBmjo6CLLPa WfndH/8lLVUi24s0HkVUzHt1KVGRLzQaxc6qI5lUaM42wWW9N0rz1KL8SgMGfhVtR/ 7Ivpdow0zR3mA== From: Nathan Chancellor To: Peter Zijlstra , x86@kernel.org Cc: Nick Desaulniers , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Nathan Chancellor Subject: [PATCH 1/2] x86/Kconfig: Only enable CONFIG_CC_HAS_IBT for clang >= 14.0.0 Date: Fri, 18 Mar 2022 16:07:46 -0700 Message-Id: <20220318230747.3900772-2-nathan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220318230747.3900772-1-nathan@kernel.org> References: <20220318230747.3900772-1-nathan@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Commit 156ff4a544ae ("x86/ibt: Base IBT bits") added a check for a crash with 'clang -fcf-protection=3Dbranch -mfentry -pg', which intended to exclude Clang versions older than 14.0.0 from selecting CONFIG_X86_KERNEL_IBT. clang-11 does not have the issue that the check is testing for, so CONFIG_X86_KERNEL_IBT is selectable. Unfortunately, there is a different crash in clang-11 that was fixed in clang-12. To make matters worse, that crash does not appear to be entirely deterministic, as the same input to the compiler will sometimes crash and other times not, which makes dynamically checking for the crash like the '-pg' one unreliable. To make everything work properly for all common versions of clang, use a hard version check of 14.0.0, as that will be the first release upstream that has both bugs properly fixed. Link: https://github.com/llvm/llvm-project/commit/e0b89df2e0f0130881bf6c39b= f31d7f6aac00e0f Signed-off-by: Nathan Chancellor --- arch/x86/Kconfig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 0f0672d2c816..921e4ebda564 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1865,9 +1865,10 @@ config CC_HAS_IBT # GCC >=3D 9 and binutils >=3D 2.29 # Retpoline check to work around https://gcc.gnu.org/bugzilla/show_bug.cg= i?id=3D93654 # Clang/LLVM >=3D 14 - # fentry check to work around https://reviews.llvm.org/D111108 + # https://github.com/llvm/llvm-project/commit/e0b89df2e0f0130881bf6c39bf3= 1d7f6aac00e0f + # https://github.com/llvm/llvm-project/commit/dfcf69770bc522b9e411c664549= 34a37c1f35332 def_bool ((CC_IS_GCC && $(cc-option, -fcf-protection=3Dbranch -mindirect-= branch-register)) || \ - (CC_IS_CLANG && $(success,echo "void a(void) {}" | $(CC) -Werror $(CLA= NG_FLAGS) -fcf-protection=3Dbranch -mfentry -pg -x c - -c -o /dev/null))) &= & \ + (CC_IS_CLANG && CLANG_VERSION >=3D 140000)) && \ $(as-instr,endbr64) =20 config X86_KERNEL_IBT --=20 2.35.1 From nobody Mon Jun 22 18:08:18 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60611C433EF for ; Fri, 18 Mar 2022 23:09:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241475AbiCRXKX (ORCPT ); Fri, 18 Mar 2022 19:10:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232891AbiCRXKU (ORCPT ); Fri, 18 Mar 2022 19:10:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E9C9F8472 for ; Fri, 18 Mar 2022 16:09:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4624CB825E7 for ; Fri, 18 Mar 2022 23:08:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99547C340F4; Fri, 18 Mar 2022 23:08:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647644938; bh=yEsoADbptHdI9cYSyIc5JdQzpMyt92hieOpRtvY3XvY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HiMLE0eA6e5GU2iyqUD/QBo0thLHb2ogej7foy+2g4erJkfD2LYKr6hrjE/OytJJ+ OfFPXBvgNfEDqTN/nZCWwq1k+pDrYWzvuCYOFTxZ0nb7raronYXtJLsart9mcVEaW/ OtcwTne91Y3GzbHtJBOKonFemtUXdBXYD2YsK4BAngSKGXr7JXQ57LAjwWiVSqnzMB d3gqaaMeaQlC0udV8a0pX0ksdxNUKuZlNHDvAjoUYHKaSUzrFAFLCkZV7Yf+9tiZmc srRsVnyROCBJROmcmFb7oZ5Hbay+6+N+9FRaNwQghDvY1LKDsv37pkrUx3TZaypOsQ EteMs7Vls+isw== From: Nathan Chancellor To: Peter Zijlstra , x86@kernel.org Cc: Nick Desaulniers , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Nathan Chancellor Subject: [PATCH 2/2] x86/Kconfig: Only allow CONFIG_X86_KERNEL_IBT with ld.lld >= 14.0.0 Date: Fri, 18 Mar 2022 16:07:47 -0700 Message-Id: <20220318230747.3900772-3-nathan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220318230747.3900772-1-nathan@kernel.org> References: <20220318230747.3900772-1-nathan@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" With CONFIG_X86_KERNEL_IBT=3Dy and a version of ld.lld prior to 14.0.0, there are numerous objtool warnings along the lines of: warning: objtool: .plt+0x6: indirect jump found in RETPOLINE build This is a known issue that has been resolved in ld.lld 14.0.0. Prevent CONFIG_X86_KERNEL_IBT from being selectable when using one of these problematic ld.lld versions. Link: https://github.com/llvm/llvm-project/commit/9d7001eba9c4cb311e03cd8cd= c231f9e579f2d0f Signed-off-by: Nathan Chancellor --- arch/x86/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 921e4ebda564..87579264aa00 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1875,6 +1875,8 @@ config X86_KERNEL_IBT prompt "Indirect Branch Tracking" bool depends on X86_64 && CC_HAS_IBT && STACK_VALIDATION + # https://github.com/llvm/llvm-project/commit/9d7001eba9c4cb311e03cd8cdc2= 31f9e579f2d0f + depends on !LD_IS_LLD || LLD_VERSION >=3D 140000 help Build the kernel with support for Indirect Branch Tracking, a hardware support course-grain forward-edge Control Flow Integrity --=20 2.35.1