Re: [RFC 06/13] cifs: Add a function to Hash the contents of an iterator

Herbert Xu
2023-01-27T10:27:35Z

David Howells <dhowells@redhat.com> 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 <crypto/aead.h>
>
> +/*
> + * 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 <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt