Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C0155675 for ; Fri, 19 May 2023 09:38:05 +0000 (UTC) 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 E135F210D; Fri, 19 May 2023 02:37:34 -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 1pzwWa-00ApJo-MZ; Fri, 19 May 2023 17:35:49 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 19 May 2023 17:35:48 +0800 Date: Fri, 19 May 2023 17:35:48 +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: Re: [PATCH] crypto: shash - Allow cloning on algorithms with no init_tfm Message-ID: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 On Fri, May 19, 2023 at 11:31:30AM +0200, Ard Biesheuvel wrote: > > OK. So IIUC, cloning a keyless hash just shares the TFM and bumps the > refcount, but here we must actually allocate a new TFM referring to > the same algo, and this new TFM needs its key to be set before use, as > it doesn't inherit it from the clonee, right? And this works in the > same way as cloning an instance of the generic HMAC template, as this > will just clone the inner shash too, and will also leave the key > unset. Yes that's pretty much it. Cloning a tfm is basically exactly the same as allocating a tfm, except that instead of going through the init_tfm code-path it executes clone_tfm instead (thus allowing any internal data structures to either be shared or allocated with GFP_ATOMIC). The key will be unset just like a freshly allocated tfm. > If so, > > Acked-by: Ard Biesheuvel Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt