Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp167262rwb; Wed, 14 Dec 2022 15:34:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf4A8wLwBVW0qJaf9BbCcHzzS/+sn2T5pwsQfbBARB3P2E95/7e+KBzFLgyiFlWrUb8U6HnD X-Received: by 2002:a50:ec8d:0:b0:46c:a3c1:2057 with SMTP id e13-20020a50ec8d000000b0046ca3c12057mr22206412edr.29.1671060876951; Wed, 14 Dec 2022 15:34:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671060876; cv=none; d=google.com; s=arc-20160816; b=sirW2RfXK1RP0rkpZJQZBA8aphs3WPC+BDtD7Gm8alzX6YFA+s9hbdgVeQPSqkWsVx sOOh6LDU7BaMIIaxbNCjXL5OLtx8d7Z8z1uJuKwz7UOcY6WA8aTGAHziKrvk4Q8tWaa2 GYZl/3Y5ah+TQwCUI8nffsO3gsTE6oXjWWGVcbkCNULj9T20BlZ0Y8kC2heCMGQ8CXCs 3zTtwuB2u5mDErqlMaT0JLEAD6Wg9E4D/V9Gu3IHlBIKq0AsEIwKo/Q/xr45UjR4BPhK QvuQYPG6eSi4ZqSI9/nkjex/zAwdWMwzxKgkkl2ilEEpRfF8wByueDU9uqxxcIMn4f6u lRhg== 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=wtWLcTpEZv8KkGAQ6rlxAjRTtvs5ZHVe1g0xx+ZaS+0=; b=Gdsv0kyO7168UWZyXoawF3KCH2xarEZW8nB28yb7aRDnQxgV32jBKYc+E6KS1Vdd8T kSVa5O+F9DwvLeYrXPqpvSA1HBKf85Y/YVWKTxICFdBk4GbVRuzjohuSzMeyV/OgYv8j 1p1PLW0DuB4QHlGH57e33wL6gwsgA39Mk1jc55YoFJIVKQg5Ykv0uI7IXj3EV7Ud9Soh J3vgUYEapdBye4JyfplWzak/Lk7Cqx5kuPU5HQbs5Z1bZv3SPF+ma2Rr5IIa61KdYmIN Z4MIBIQGMBiIW+r5BHyQDxZsCwdKmzyS857UpA8EAWWt6P/QVV5mJwWt66jYlL2JI+l2 /FPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dVVEHCmy; 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 i42-20020a0564020f2a00b00456eaa4fb1fsi12061862eda.223.2022.12.14.15.34.19; Wed, 14 Dec 2022 15:34:36 -0800 (PST) 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=dVVEHCmy; 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 S229841AbiLNX3Q (ORCPT + 70 others); Wed, 14 Dec 2022 18:29:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229838AbiLNX2N (ORCPT ); Wed, 14 Dec 2022 18:28:13 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB053511EE; Wed, 14 Dec 2022 15:26:38 -0800 (PST) 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 568B361BF8; Wed, 14 Dec 2022 23:26:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AB6DC433D2; Wed, 14 Dec 2022 23:26:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671060397; bh=kkfEQgwWyo+kPv5VWEAu/1iunwHHV2AQpSwt9ibZlUY=; h=From:To:Cc:Subject:Date:From; b=dVVEHCmymGa2rwiZytT5fwntuTx84t4e8vd1gx8FET1GJQpYgyYAdH9sdZ6Fr0CMY PhprWN1t/BNlbT578Bu8t/D0NWQ8QYTm6GsFTklgMpS6nlzbg+MYzKdvZmzZfpEc5F GHfAWvSnHtPJSjQD4C6UE0FSwvw8m5ukX8KkqT1arsj6v6EwP93inuCfI8WbefQ3Tu u7sP8cx+q1AxHS0YUQ/L73VaoxaB/x/5q3azqCaC7N2uMJqgzv73aNDbqThJkg0z9j GhQDq3zEEr5mVG6lztAWvl8pfJ/0LoE25pd4Mlu5zfuNMVqjVCd/gPxyEeDBD0QZTm /TaWkt4hlXdGg== From: Nathan Chancellor To: Kees Cook , Nick Desaulniers Cc: Tom Rix , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, Nathan Chancellor , stable@vger.kernel.org Subject: [PATCH] security: Restrict CONFIG_ZERO_CALL_USED_REGS to gcc or clang > 15.0.6 Date: Wed, 14 Dec 2022 16:26:03 -0700 Message-Id: <20221214232602.4118147-1-nathan@kernel.org> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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 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 A bad bug in clang's implementation of -fzero-call-used-regs can result in NULL pointer dereferences (see the links above the check for more information). Restrict CONFIG_CC_HAS_ZERO_CALL_USED_REGS to either a supported GCC version or a clang newer than 15.0.6, which will catch both a theoretical 15.0.7 and the upcoming 16.0.0, which will both have the bug fixed. Cc: stable@vger.kernel.org # v5.15+ Signed-off-by: Nathan Chancellor --- security/Kconfig.hardening | 3 +++ 1 file changed, 3 insertions(+) diff --git a/security/Kconfig.hardening b/security/Kconfig.hardening index d766b7d0ffd1..53baa95cb644 100644 --- a/security/Kconfig.hardening +++ b/security/Kconfig.hardening @@ -257,6 +257,9 @@ config INIT_ON_FREE_DEFAULT_ON config CC_HAS_ZERO_CALL_USED_REGS def_bool $(cc-option,-fzero-call-used-regs=used-gpr) + # https://github.com/ClangBuiltLinux/linux/issues/1766 + # https://github.com/llvm/llvm-project/issues/59242 + depends on !CC_IS_CLANG || CLANG_VERSION > 150006 config ZERO_CALL_USED_REGS bool "Enable register zeroing on function exit" base-commit: 830b3c68c1fb1e9176028d02ef86f3cf76aa2476 -- 2.39.0