Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2184206rwd; Fri, 19 May 2023 02:06:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7qOhC95C7mWmZFgVSqmkRYvhIoi7d7+gRp8F+eBBCHrSXq2Uttz1Y2L53EEzqQmsXTgnLx X-Received: by 2002:a05:6a20:510:b0:104:2226:1b96 with SMTP id 16-20020a056a20051000b0010422261b96mr1368856pzp.22.1684487160662; Fri, 19 May 2023 02:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684487160; cv=none; d=google.com; s=arc-20160816; b=QGudP8+hqJmCeMl8JZe9AVXTBbLDd4YYgD2R1WSVYmHKllU/DTX8ywQSIswfXlK6Eu QDc3CnbP5WYkiXXlu0rVmFe1MQGWHovgAsQ4tS4EYFfcGtL2dAJdb8Ai02BHHRP2G+hA R1o0XAT0CcRCEV7hL8ABS8dLQXpt3012J+ESEJOyl7gzbGdgp8X+7d7lMgRTTKoE0h0o CyTiUQ/TO5BWU0U7hAwf3jyU2D92dUpQMMwtcABtRHb4BVYTc62bxGHLvdWn85sNrWC6 49M0v5sCtrbc1HHwCj7DTD/95/aOG3LLTSw/VdTj6OKsU/To2Q9IdAGrCzmWEhHv2pkj 7FJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=VI2M8NBxYImeBrFfjJvlOBr3dyY/ScXzx6drfiEUtw0=; b=F0d9FBp/Glvrs7Tlj4o4IlldFatBqvs1kjoxVkcopIt2u4809aYHT+jTnMENYkca/q Ms/wr6TsD8+3l22EZ88gGJk/S9ieDG7Se44cqArl5x52GshUav3OKnwg9UBdiRrdA6/e luuDkxxJeyM6Y+9Rt/TLSmIjM9ixLWPiZSSJEJ9UF27jDaI5Xe6wKJy7AluHJ915cHdh xxlRNZ4u3P1pkPxsFlxAznGY4DqaLgVG/ad6scPutnpn3IDLeiNTmhWP0EAA7Tbx+EHE SByr6Rw4OMxDkN/i+8vvybpaPxpsgqT6yA0U8fc3kvcXAFNHd/e8Ywe5MC6I4ew0cB25 y5SA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bs132-20020a63288a000000b004fb171df693si3267209pgb.352.2023.05.19.02.05.45; Fri, 19 May 2023 02:06:00 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230147AbjESJFn (ORCPT + 99 others); Fri, 19 May 2023 05:05:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229876AbjESJFm (ORCPT ); Fri, 19 May 2023 05:05:42 -0400 Received: from 167-179-156-38.a7b39c.syd.nbn.aussiebb.net (167-179-156-38.a7b39c.syd.nbn.aussiebb.net [167.179.156.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 653FE1723; Fri, 19 May 2023 02:05:15 -0700 (PDT) Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1pzw1s-00AoNA-Ne; Fri, 19 May 2023 17:04:05 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 19 May 2023 17:04:04 +0800 Date: Fri, 19 May 2023 17:04:04 +0800 From: Herbert Xu To: Ard Biesheuvel Cc: Dmitry Safonov , Linux Crypto Mailing List , linux-kernel@vger.kernel.org, David Ahern , Eric Dumazet , Paolo Abeni , Jakub Kicinski , "David S. Miller" , Andy Lutomirski , Bob Gilligan , Dan Carpenter , David Laight , Dmitry Safonov <0x7f454c46@gmail.com>, Eric Biggers , "Eric W. Biederman" , Francesco Ruggeri , Hideaki YOSHIFUJI , Ivan Delalande , Leonard Crestez , Salam Noureddine , netdev@vger.kernel.org Subject: [PATCH] crypto: shash - Allow cloning on algorithms with no init_tfm Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=2.7 required=5.0 tests=BAYES_00,HELO_DYNAMIC_IPADDR2, RDNS_DYNAMIC,SPF_HELO_NONE,SPF_PASS,TVD_RCVD_IP,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** 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 On Fri, May 19, 2023 at 10:54:11AM +0200, Ard Biesheuvel wrote: > > Does this imply that the cmac-aes-ce and cmac-aes-neon implementations > for arm64 need a similar treatment? Good catch. Since these don't have init functions we can deal with them at a higher level: ---8<--- Some shash algorithms are so simple that they don't have an init_tfm function. These can be cloned trivially. Check this before failing in crypto_clone_shash. Signed-off-by: Herbert Xu diff --git a/crypto/shash.c b/crypto/shash.c index 717b42df3495..1fadb6b59bdc 100644 --- a/crypto/shash.c +++ b/crypto/shash.c @@ -597,7 +597,7 @@ struct crypto_shash *crypto_clone_shash(struct crypto_shash *hash) return hash; } - if (!alg->clone_tfm) + if (!alg->clone_tfm && (alg->init_tfm || alg->base.cra_init)) return ERR_PTR(-ENOSYS); nhash = crypto_clone_tfm(&crypto_shash_type, tfm); @@ -606,10 +606,12 @@ struct crypto_shash *crypto_clone_shash(struct crypto_shash *hash) nhash->descsize = hash->descsize; - err = alg->clone_tfm(nhash, hash); - if (err) { - crypto_free_shash(nhash); - return ERR_PTR(err); + if (alg->clone_tfm) { + err = alg->clone_tfm(nhash, hash); + if (err) { + crypto_free_shash(nhash); + return ERR_PTR(err); + } } return nhash; -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt