Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp290108pxp; Sat, 19 Mar 2022 02:35:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+2OV+lft10+pYL4owmBONnSxpfvAGLDGqwOJe8Q6pqn1XlarDMC1aVYmuiUrjwpNtxn/+ X-Received: by 2002:a17:90a:7304:b0:1c6:aadc:90e5 with SMTP id m4-20020a17090a730400b001c6aadc90e5mr8708931pjk.164.1647682528159; Sat, 19 Mar 2022 02:35:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647682528; cv=none; d=google.com; s=arc-20160816; b=J09jddvvhRt2/a6wEnZrDaXEm7PYOOwNyTGYLd9xIaAo/W5x/mSIUeSq7qsT4kaQM4 5OZ6T98YV0I2XrFN7i0XoV1YbSQjstuuMNfDT6mBfKWDcgQxh4D+zJacz68ahtbeis3J ExriuiHK8onb4QzXcjgqds09js48Y/O3PcfYsb3f1JBZoi/dO4Ldw/LlWnSkYBLzPe1j aCNHs+Cj5WC4odI8cJO1iiKbRErBWFNGjblJseKJhGKblplYGskau4HWXDF3gvG+gX39 NOM3MhByEqcVcymi2M1HsXtjXR3KjZ+99f7j9tZU6VU7Vw2BLfgq+5RhFm8/WYeQgU6a yysg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=AL47+ycw/+YxTTw9owsprXaM1lRqvJXQ3aLf+xqdoSc=; b=DdzDBcDZwEBhtUW6VRRD34Bd/t+fJGhoOj1ejGvn0hoas8VpGqTZ0aLSlMg7zwZUGy V4TnWr0QcIkfPuuehJ8M+S/sGYdg6OSgy/9g6YvxU4u5jhlccrEKUEn9KgWzh0l8hHEm 0iB/l6SuYBNwLcv0lOfLyCMx8ZaTur3rmZpbNv/O1gS4rkAaPiBPthA8bSu45twQqjZe Koobo7K/JJcStzIlYqQam73FfBsIs4jBdPEnl2+jqzKKCp30JGLQAvOGg0prdQnai1op xhltkuR+sbIOBAXEosXF+9ASCaMfWHrZxLULFqNwLwSbujEyp/uHgWHZh3z2IQgtA5/N VXdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K4qsOy4o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 196-20020a6301cd000000b003816043ef37si7229982pgb.300.2022.03.19.02.35.15; Sat, 19 Mar 2022 02:35:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K4qsOy4o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241065AbiCRXKQ (ORCPT + 99 others); Fri, 18 Mar 2022 19:10:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232891AbiCRXKP (ORCPT ); Fri, 18 Mar 2022 19:10:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CBD5F47EA for ; Fri, 18 Mar 2022 16:08:56 -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 BA32A61642 for ; Fri, 18 Mar 2022 23:08:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93020C340E8; Fri, 18 Mar 2022 23:08:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647644935; bh=A3Y689zBKJu2EqrYev8FF9G6KLLrbNU5CtFhDlAKkoo=; h=From:To:Cc:Subject:Date:From; b=K4qsOy4oKGHU5z7hHaHsd6/bgIdYpZCLAFxzaTTDq/Z09ALl0lZ9uuxdgJ0hEErOt K2mR/g4LceflzCDAQrtTYTVpUBPfO/3qZ2DZk/JTFDDXRR/cqc4TNvRc2iYi94J/GJ ScAmwIlveiilEFuFeRfGVyC3OL3s9Hg4/cAtaqIcDjD6Sm2+V03qsLGJPr2u3iqoFe xSugWArJvQ6PZFXSXPrYgU4OoM5uzeWeIqyYetfMgYZWnHh+NCfuTq8nLvGPkTIezK NumgA30BPJiK0dtKhO/h4Xbuk/97wgzJ9Rl9qHNbRwYf/nzmW6w4FgD17DAb6DkgFj zQGK8w9fZM5vQ== 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 0/2] Fix CONFIG_X86_KERNEL_IBT for clang and ld.lld < 14.0.0 Date: Fri, 18 Mar 2022 16:07:45 -0700 Message-Id: <20220318230747.3900772-1-nathan@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While testing -tip after the IBT bits were merged, our continuous integration noticed a crash with clang-11: https://builds.tuxbuild.com/26ZRIuAPHx1L802ExiYCuLuvMhK/build.log This crash is a separate issue from the one that is already being checked for with '-fcf-protection=branch -mfentry -pg'. This new crash was fixed in clang-12: https://github.com/llvm/llvm-project/commit/e0b89df2e0f0130881bf6c39bf31d7f6aac00e0f Unfortunately, I have not been able to tease out a simplified reproducer for this crash that always triggers. The reproducer in that commit message and the reproducer commented in the LLVM test do not trigger all the time (at least with the clang-11 that is in Debian/Ubuntu, assertions might make the crash always happen but we cannot count on that); even the full preprocessed files straight from the kernel source do not always trigger a crash. As a result, this series proposes just having a hard version check for clang 14.0.0 and newer, which will cover this new clang-11 crash and the '-fcf-protection=branch -mfentry -pg' crash. Adding a check for a version of clang that has not been released yet is a little riskier than dynamically testing the clang binary for an issue, as it is possible that someone is using/testing a version of clang from before a particular issue was fixed, while still having the same version number. However, our policy for version checks in the kernel has always been to use the final version of clang that will have the issue fixed, as people should be upgrading their compilers often if they are using prereleased versions. In this particular instance, the '-fcf-protection=branch -mfentry -pg' crash has been fixed for over three months, which is plenty of time to upgrade: https://github.com/llvm/llvm-project/commit/dfcf69770bc522b9e411c66454934a37c1f35332 At the moment, I only know of one version of clang that is fairly widely used that will show this crash, which is Android's clang 14.0.2. We are in the process of getting a newer version (14.0.3) deployed to minimize the impact this change will have on various testing groups: https://android-review.googlesource.com/c/kernel/common/+/2032664 https://android-review.googlesource.com/c/kernel/common/+/2032665 https://android-review.googlesource.com/c/kernel/common/+/2032666 https://gitlab.com/Linaro/tuxmake/-/merge_requests/244 If for some reason there are any reports of issues after this change, feel free to direct them to this cover letter and tell them to upgrade their compiler :) The second patch just codifies the result of this discussion and issue: https://lore.kernel.org/r/202202241627.EEF3D5D2@keescook/ https://github.com/ClangBuiltLinux/linux/issues/1606 This is based on -tip x86/core and it has survived an allmodconfig build with clang-11 through clang-15 (CC=clang and LLVM=1). Nathan Chancellor (2): x86/Kconfig: Only enable CONFIG_CC_HAS_IBT for clang >= 14.0.0 x86/Kconfig: Only allow CONFIG_X86_KERNEL_IBT with ld.lld >= 14.0.0 arch/x86/Kconfig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) base-commit: 2f35e67f621fffc636cb802a4f93fd168cf38274 -- 2.35.1