From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6145C61DA7 for ; Fri, 27 Jan 2023 10:27:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230487AbjA0K1e (ORCPT ); Fri, 27 Jan 2023 05:27:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbjA0K1d (ORCPT ); Fri, 27 Jan 2023 05:27:33 -0500 Received: from formenos.hmeau.com (helcar.hmeau.com [216.24.177.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07D3F2A175; Fri, 27 Jan 2023 02:27:32 -0800 (PST) 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 1pLLwl-004gF4-LQ; Fri, 27 Jan 2023 18:27:04 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 27 Jan 2023 18:27:03 +0800 Date: Fri, 27 Jan 2023 18:27:03 +0800 From: Herbert Xu To: David Howells Cc: smfrench@gmail.com, dhowells@redhat.com, viro@zeniv.linux.org.uk, nspmangalore@gmail.com, rohiths.msft@gmail.com, tom@talpey.com, metze@samba.org, hch@infradead.org, willy@infradead.org, jlayton@kernel.org, linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, sfrench@samba.org, linux-crypto@vger.kernel.org Subject: Re: [RFC 06/13] cifs: Add a function to Hash the contents of an iterator Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230125214543.2337639-7-dhowells@redhat.com> X-Newsgroups: apana.lists.os.linux.cryptoapi,apana.lists.os.linux.kernel Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org David Howells wrote: > > diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c > index cbc18b4a9cb2..7be589aeb520 100644 > --- a/fs/cifs/cifsencrypt.c > +++ b/fs/cifs/cifsencrypt.c > @@ -24,6 +24,150 @@ > #include "../smbfs_common/arc4.h" > #include > > +/* > + * Hash data from a BVEC-type iterator. > + */ > +static int cifs_shash_bvec(const struct iov_iter *iter, ssize_t maxsize, > + struct shash_desc *shash) > +{ > + const struct bio_vec *bv = iter->bvec; > + unsigned long start = iter->iov_offset; > + unsigned int i; > + void *p; > + int ret; > + > + for (i = 0; i < iter->nr_segs; i++) { > + size_t off, len; > + > + len = bv[i].bv_len; > + if (start >= len) { > + start -= len; > + continue; > + } > + > + len = min_t(size_t, maxsize, len - start); > + off = bv[i].bv_offset + start; > + > + p = kmap_local_page(bv[i].bv_page); > + ret = crypto_shash_update(shash, p + off, len); Please convert this to ahash. The whole point of shash is to process *small* amounts of data that is not on an SG list. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt