linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: bfields@fieldses.org (J. Bruce Fields)
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-crypto@vger.kernel.org, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 15/20] nfsd: use crypto_shash_tfm_digest()
Date: Mon, 4 May 2020 15:09:54 -0400	[thread overview]
Message-ID: <20200504190954.GC2757@fieldses.org> (raw)
In-Reply-To: <20200502053122.995648-16-ebiggers@kernel.org>

On Fri, May 01, 2020 at 10:31:17PM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> Instead of manually allocating a 'struct shash_desc' on the stack and
> calling crypto_shash_digest(), switch to using the new helper function
> crypto_shash_tfm_digest() which does this for us.
> 
> Cc: linux-nfs@vger.kernel.org
> Signed-off-by: Eric Biggers <ebiggers@google.com>

Acked-by: J. Bruce Fields <bfields@redhat.com>

if you need it.

--b.

> ---
>  fs/nfsd/nfs4recover.c | 26 ++++++--------------------
>  1 file changed, 6 insertions(+), 20 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
> index a8fb18609146a2..9e40dfecf1b1a6 100644
> --- a/fs/nfsd/nfs4recover.c
> +++ b/fs/nfsd/nfs4recover.c
> @@ -127,16 +127,8 @@ nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname)
>   		goto out;
>  	}
>  
> -	{
> -		SHASH_DESC_ON_STACK(desc, tfm);
> -
> -		desc->tfm = tfm;
> -
> -		status = crypto_shash_digest(desc, clname->data, clname->len,
> -					     cksum.data);
> -		shash_desc_zero(desc);
> -	}
> -
> +	status = crypto_shash_tfm_digest(tfm, clname->data, clname->len,
> +					 cksum.data);
>  	if (status)
>  		goto out;
>  
> @@ -1148,7 +1140,6 @@ nfsd4_cld_create_v2(struct nfs4_client *clp)
>  	struct crypto_shash *tfm = cn->cn_tfm;
>  	struct xdr_netobj cksum;
>  	char *principal = NULL;
> -	SHASH_DESC_ON_STACK(desc, tfm);
>  
>  	/* Don't upcall if it's already stored */
>  	if (test_bit(NFSD4_CLIENT_STABLE, &clp->cl_flags))
> @@ -1170,16 +1161,14 @@ nfsd4_cld_create_v2(struct nfs4_client *clp)
>  	else if (clp->cl_cred.cr_principal)
>  		principal = clp->cl_cred.cr_principal;
>  	if (principal) {
> -		desc->tfm = tfm;
>  		cksum.len = crypto_shash_digestsize(tfm);
>  		cksum.data = kmalloc(cksum.len, GFP_KERNEL);
>  		if (cksum.data == NULL) {
>  			ret = -ENOMEM;
>  			goto out;
>  		}
> -		ret = crypto_shash_digest(desc, principal, strlen(principal),
> -					  cksum.data);
> -		shash_desc_zero(desc);
> +		ret = crypto_shash_tfm_digest(tfm, principal, strlen(principal),
> +					      cksum.data);
>  		if (ret) {
>  			kfree(cksum.data);
>  			goto out;
> @@ -1343,7 +1332,6 @@ nfsd4_cld_check_v2(struct nfs4_client *clp)
>  	struct crypto_shash *tfm = cn->cn_tfm;
>  	struct xdr_netobj cksum;
>  	char *principal = NULL;
> -	SHASH_DESC_ON_STACK(desc, tfm);
>  
>  	/* did we already find that this client is stable? */
>  	if (test_bit(NFSD4_CLIENT_STABLE, &clp->cl_flags))
> @@ -1381,14 +1369,12 @@ nfsd4_cld_check_v2(struct nfs4_client *clp)
>  			principal = clp->cl_cred.cr_principal;
>  		if (principal == NULL)
>  			return -ENOENT;
> -		desc->tfm = tfm;
>  		cksum.len = crypto_shash_digestsize(tfm);
>  		cksum.data = kmalloc(cksum.len, GFP_KERNEL);
>  		if (cksum.data == NULL)
>  			return -ENOENT;
> -		status = crypto_shash_digest(desc, principal, strlen(principal),
> -					     cksum.data);
> -		shash_desc_zero(desc);
> +		status = crypto_shash_tfm_digest(tfm, principal,
> +						 strlen(principal), cksum.data);
>  		if (status) {
>  			kfree(cksum.data);
>  			return -ENOENT;
> -- 
> 2.26.2

  reply	other threads:[~2020-05-04 19:09 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-02  5:31 [PATCH 00/20] crypto: introduce crypto_shash_tfm_digest() Eric Biggers
2020-05-02  5:31 ` [PATCH 01/20] crypto: hash - " Eric Biggers
2020-05-02  5:31 ` [PATCH 02/20] crypto: arm64/aes-glue - use crypto_shash_tfm_digest() Eric Biggers
2020-05-02  5:31 ` [PATCH 03/20] crypto: essiv " Eric Biggers
2020-05-02  5:31 ` [PATCH 04/20] crypto: artpec6 " Eric Biggers
2020-05-02  5:31 ` [PATCH 05/20] crypto: ccp " Eric Biggers
2020-05-07 21:23   ` Tom Lendacky
2020-05-02  5:31 ` [PATCH 06/20] crypto: ccree " Eric Biggers
2020-05-03 14:01   ` Gilad Ben-Yossef
2020-05-02  5:31 ` [PATCH 07/20] crypto: hisilicon/sec2 " Eric Biggers
2020-05-02  5:31 ` [PATCH 08/20] crypto: mediatek " Eric Biggers
2020-05-02  5:31 ` [PATCH 09/20] crypto: n2 " Eric Biggers
2020-05-02  5:31 ` [PATCH 10/20] crypto: omap-sham " Eric Biggers
2020-05-02  5:31 ` [PATCH 11/20] crypto: s5p-sss " Eric Biggers
2020-05-05 14:19   ` Krzysztof Kozlowski
2020-05-02  5:31 ` [PATCH 12/20] nfc: s3fwrn5: " Eric Biggers
2020-05-02  5:31 ` [PATCH 13/20] fscrypt: " Eric Biggers
2020-05-02  5:31 ` [PATCH 14/20] ecryptfs: " Eric Biggers
2020-05-02  5:31 ` [PATCH 15/20] nfsd: " Eric Biggers
2020-05-04 19:09   ` J. Bruce Fields [this message]
2020-05-02  5:31 ` [PATCH 16/20] ubifs: " Eric Biggers
2020-05-02  5:31 ` [PATCH 17/20] Bluetooth: " Eric Biggers
2020-05-02  5:31 ` [PATCH 18/20] sctp: " Eric Biggers
2020-05-02  5:31 ` [PATCH 19/20] KEYS: encrypted: " Eric Biggers
2020-05-02  5:31 ` [PATCH 20/20] ASoC: cros_ec_codec: " Eric Biggers
2020-05-02  6:44 ` [PATCH 00/20] crypto: introduce crypto_shash_tfm_digest() Marcel Holtmann
2020-05-03 16:13 ` Ard Biesheuvel
2020-05-08  6:07 ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200504190954.GC2757@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=ebiggers@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).