Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp287988rwb; Fri, 18 Nov 2022 01:12:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf4zrea0bgxUsfclg+dEIXEZWYI4C026epp8EPiRsXkOsYM+/Qi1ZH8p0320um4k1QGvk6JX X-Received: by 2002:a17:906:eb10:b0:78e:2ba7:70f6 with SMTP id mb16-20020a170906eb1000b0078e2ba770f6mr5325150ejb.382.1668762752268; Fri, 18 Nov 2022 01:12:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668762752; cv=none; d=google.com; s=arc-20160816; b=tuuD9/Yz+PsV+qvzFIxiPe28u3KBkQl0bgPOsfKhzLpsWsGsZLVGSxHJugMw2CU6c1 sr16uttqBQcQEePrGHPvbzo8hU+JYComoZp1q22QuTvscfPy6Bm85DMvdzp3MzVmTQHW Bcrgv45WrojR4MzLSlxWdbTmyLpN321uquQmhhymAYNzki0Vz+LNURm6sNVJFPiuUlyH Gm9a6AibHg36j1TuRWgr4A2Mzq/fvCHEXY8e3ObGMoOy5Ikmv0vpYCzlvTnxXuykxSc7 yfQSediPx6Yjf7k/kDz0ANQWTNIrjC8lwQsok5JsqBUfQYJ3zGO2pVpo13O6rXP11ENN 2tzA== 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 :dkim-signature; bh=1uaEfelK0/ZvXq/IuXnWefcz8Wg3/V/JgQXtRs4CXJ0=; b=XLu8GOtMOYq8Imj5s0S68GTAKvSgkbNlUtNYfb0+ytQ1XdrQUF8v3+56O1VEG9cU8g yeK5ga+tt2AE/2+8Itt4xA9+Ui6gxMl6OtruKEXeIoFaSdU++vm3za3ABNThIkU/Whnc poZATyZCxQWiqc4T9KaVMamWbxxXSgfqCDNFO9+DrHU0DflNxLPOmo0mtCItYiX+3wzV lgGc9VTQ0qmx+SrB5ihAWvsxMEU9I19psLYFNWmX/1SmudtXlyhL2RkVKsldYXT3xkR+ oUV5hBRCSSIiKEpW+HaxwoKRaO2clSzg7Yk03ui93hw1u3UezYNrizXnqV2SOlnizBsG C8kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=liqNp19o; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-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 wd3-20020a170907d60300b007ae72eabbcbsi2525489ejc.824.2022.11.18.01.12.06; Fri, 18 Nov 2022 01:12:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-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=liqNp19o; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-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 S241709AbiKRJEW (ORCPT + 99 others); Fri, 18 Nov 2022 04:04:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241426AbiKRJEQ (ORCPT ); Fri, 18 Nov 2022 04:04:16 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89BA182BFA for ; Fri, 18 Nov 2022 01:04:11 -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 10514623B1 for ; Fri, 18 Nov 2022 09:04:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B7DCC43141; Fri, 18 Nov 2022 09:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668762250; bh=dN9lqJsqSknnJEVWfdbcH4PBv1COtt2elsbRPuqKWpA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=liqNp19oNyCipr9vwmUXYl94kRjIRI2R4Ks7FBDJWaZW/5/EuRAhr/i12ZO3dqwJP sIqNH+Jm/2M9dp86/CFzURzWn2glS35cKQ90JbEiRXZMJTCuw0I530QCO8Ky/pLakU 7PwI6ceXuN1oko89Q51kX8xlOEHPjAWuCrwXNpwKbkPJgppTkcii8c6fzUwxrE50SL 4rlviybpw4WjTC11URRRuqmpOza2fS6yhoHkrimgQPFWhu8jVzuWuUD5F1G/NIr9sn b93AtG0dxbXnWmfEoxmRkT4wW7raI2Wcmz1wMFy8WG+BQpTJpHTq1hVIFMbypx0MST U6EzSEKEO/KtA== From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, Sami Tolvanen Subject: [PATCH 11/11] Revert "crypto: shash - avoid comparing pointers to exported functions under CFI" Date: Fri, 18 Nov 2022 01:02:20 -0800 Message-Id: <20221118090220.398819-12-ebiggers@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221118090220.398819-1-ebiggers@kernel.org> References: <20221118090220.398819-1-ebiggers@kernel.org> 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-crypto@vger.kernel.org From: Eric Biggers This reverts commit 22ca9f4aaf431a9413dcc115dd590123307f274f because CFI no longer breaks cross-module function address equality, so crypto_shash_alg_has_setkey() can now be an inline function like before. This commit should not be backported to kernels that don't have the new CFI implementation. Signed-off-by: Eric Biggers --- crypto/shash.c | 18 +++--------------- include/crypto/internal/hash.h | 8 +++++++- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/crypto/shash.c b/crypto/shash.c index 4c88e63b3350f..0f85431588267 100644 --- a/crypto/shash.c +++ b/crypto/shash.c @@ -20,24 +20,12 @@ static const struct crypto_type crypto_shash_type; -static int shash_no_setkey(struct crypto_shash *tfm, const u8 *key, - unsigned int keylen) +int shash_no_setkey(struct crypto_shash *tfm, const u8 *key, + unsigned int keylen) { return -ENOSYS; } - -/* - * Check whether an shash algorithm has a setkey function. - * - * For CFI compatibility, this must not be an inline function. This is because - * when CFI is enabled, modules won't get the same address for shash_no_setkey - * (if it were exported, which inlining would require) as the core kernel will. - */ -bool crypto_shash_alg_has_setkey(struct shash_alg *alg) -{ - return alg->setkey != shash_no_setkey; -} -EXPORT_SYMBOL_GPL(crypto_shash_alg_has_setkey); +EXPORT_SYMBOL_GPL(shash_no_setkey); static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key, unsigned int keylen) diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h index 25806141db591..0a288dddcf5be 100644 --- a/include/crypto/internal/hash.h +++ b/include/crypto/internal/hash.h @@ -75,7 +75,13 @@ void crypto_unregister_ahashes(struct ahash_alg *algs, int count); int ahash_register_instance(struct crypto_template *tmpl, struct ahash_instance *inst); -bool crypto_shash_alg_has_setkey(struct shash_alg *alg); +int shash_no_setkey(struct crypto_shash *tfm, const u8 *key, + unsigned int keylen); + +static inline bool crypto_shash_alg_has_setkey(struct shash_alg *alg) +{ + return alg->setkey != shash_no_setkey; +} static inline bool crypto_shash_alg_needs_key(struct shash_alg *alg) { -- 2.38.1