public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/20] crypto: introduce crypto_shash_tfm_digest()
@ 2020-05-02  5:31 Eric Biggers
  2020-05-02  5:31 ` [PATCH 01/20] crypto: hash - " Eric Biggers
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Eric Biggers @ 2020-05-02  5:31 UTC (permalink / raw)
  To: linux-crypto
  Cc: Cheng-Yi Chiang, ecryptfs, Enric Balletbo i Serra,
	Gilad Ben-Yossef, Guenter Roeck, Jesper Nilsson, Kamil Konieczny,
	keyrings, Krzysztof Kozlowski, Krzysztof Opasiak, Lars Persson,
	linux-bluetooth, linux-mtd, linux-nfs, linux-sctp, Robert Baldyga,
	Tom Lendacky, Vladimir Zapolskiy, Zaibo Xu

This series introduces a helper function crypto_shash_tfm_digest() which
replaces the following common pattern:

	{
		SHASH_DESC_ON_STACK(desc, tfm);
		int err;

		desc->tfm = tfm;

		err = crypto_shash_digest(desc, data, len, out);

		shash_desc_zero(desc);
	}

with:

	err = crypto_shash_tfm_digest(tfm, data, len, out);

Patch 1 introduces this helper function, and patches 2-20 convert all
relevant users to use it.

IMO, it would be easiest to take all these patches through the crypto
tree.  But taking just the "crypto:" ones and then me trying to get the
rest merged later via subsystem trees is also an option.

Eric Biggers (20):
  crypto: hash - introduce crypto_shash_tfm_digest()
  crypto: arm64/aes-glue - use crypto_shash_tfm_digest()
  crypto: essiv - use crypto_shash_tfm_digest()
  crypto: artpec6 - use crypto_shash_tfm_digest()
  crypto: ccp - use crypto_shash_tfm_digest()
  crypto: ccree - use crypto_shash_tfm_digest()
  crypto: hisilicon/sec2 - use crypto_shash_tfm_digest()
  crypto: mediatek - use crypto_shash_tfm_digest()
  crypto: n2 - use crypto_shash_tfm_digest()
  crypto: omap-sham - use crypto_shash_tfm_digest()
  crypto: s5p-sss - use crypto_shash_tfm_digest()
  nfc: s3fwrn5: use crypto_shash_tfm_digest()
  fscrypt: use crypto_shash_tfm_digest()
  ecryptfs: use crypto_shash_tfm_digest()
  nfsd: use crypto_shash_tfm_digest()
  ubifs: use crypto_shash_tfm_digest()
  Bluetooth: use crypto_shash_tfm_digest()
  sctp: use crypto_shash_tfm_digest()
  KEYS: encrypted: use crypto_shash_tfm_digest()
  ASoC: cros_ec_codec: use crypto_shash_tfm_digest()

 arch/arm64/crypto/aes-glue.c               |  4 +--
 crypto/essiv.c                             |  4 +--
 crypto/shash.c                             | 16 +++++++++
 drivers/crypto/axis/artpec6_crypto.c       | 10 ++----
 drivers/crypto/ccp/ccp-crypto-sha.c        |  9 ++---
 drivers/crypto/ccree/cc_cipher.c           |  9 ++---
 drivers/crypto/hisilicon/sec2/sec_crypto.c |  5 ++-
 drivers/crypto/mediatek/mtk-sha.c          |  7 ++--
 drivers/crypto/n2_core.c                   |  7 ++--
 drivers/crypto/omap-sham.c                 | 20 +++--------
 drivers/crypto/s5p-sss.c                   | 39 ++++------------------
 drivers/nfc/s3fwrn5/firmware.c             | 10 +-----
 fs/crypto/fname.c                          |  7 +---
 fs/crypto/hkdf.c                           |  6 +---
 fs/ecryptfs/crypto.c                       | 17 +---------
 fs/nfsd/nfs4recover.c                      | 26 ++++-----------
 fs/ubifs/auth.c                            | 20 ++---------
 fs/ubifs/master.c                          |  9 ++---
 fs/ubifs/replay.c                          | 14 ++------
 include/crypto/hash.h                      | 19 +++++++++++
 net/bluetooth/smp.c                        |  6 +---
 net/sctp/auth.c                            | 10 ++----
 net/sctp/sm_make_chunk.c                   | 23 +++++--------
 security/keys/encrypted-keys/encrypted.c   | 18 ++--------
 sound/soc/codecs/cros_ec_codec.c           |  9 +----
 25 files changed, 95 insertions(+), 229 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 01/20] crypto: hash - introduce crypto_shash_tfm_digest()
  2020-05-02  5:31 [PATCH 00/20] crypto: introduce crypto_shash_tfm_digest() Eric Biggers
@ 2020-05-02  5:31 ` Eric Biggers
  2020-05-02  5:31 ` [PATCH 15/20] nfsd: use crypto_shash_tfm_digest() Eric Biggers
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Eric Biggers @ 2020-05-02  5:31 UTC (permalink / raw)
  To: linux-crypto
  Cc: Cheng-Yi Chiang, ecryptfs, Enric Balletbo i Serra,
	Gilad Ben-Yossef, Guenter Roeck, Jesper Nilsson, Kamil Konieczny,
	keyrings, Krzysztof Kozlowski, Krzysztof Opasiak, Lars Persson,
	linux-bluetooth, linux-mtd, linux-nfs, linux-sctp, Robert Baldyga,
	Tom Lendacky, Vladimir Zapolskiy, Zaibo Xu

From: Eric Biggers <ebiggers@google.com>

Currently the simplest use of the shash API is to use
crypto_shash_digest() to digest a whole buffer.  However, this still
requires allocating a hash descriptor (struct shash_desc).  Many users
don't really want to preallocate one and instead just use a one-off
descriptor on the stack like the following:

	{
		SHASH_DESC_ON_STACK(desc, tfm);
		int err;

		desc->tfm = tfm;

		err = crypto_shash_digest(desc, data, len, out);

		shash_desc_zero(desc);
	}

Wrap this in a new helper function crypto_shash_tfm_digest() that can be
used instead of the above.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 crypto/shash.c        | 16 ++++++++++++++++
 include/crypto/hash.h | 19 +++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/crypto/shash.c b/crypto/shash.c
index c075b26c2a1d9f..e6a4b5f39b8c64 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -206,6 +206,22 @@ int crypto_shash_digest(struct shash_desc *desc, const u8 *data,
 }
 EXPORT_SYMBOL_GPL(crypto_shash_digest);
 
+int crypto_shash_tfm_digest(struct crypto_shash *tfm, const u8 *data,
+			    unsigned int len, u8 *out)
+{
+	SHASH_DESC_ON_STACK(desc, tfm);
+	int err;
+
+	desc->tfm = tfm;
+
+	err = crypto_shash_digest(desc, data, len, out);
+
+	shash_desc_zero(desc);
+
+	return err;
+}
+EXPORT_SYMBOL_GPL(crypto_shash_tfm_digest);
+
 static int shash_default_export(struct shash_desc *desc, void *out)
 {
 	memcpy(out, shash_desc_ctx(desc), crypto_shash_descsize(desc->tfm));
diff --git a/include/crypto/hash.h b/include/crypto/hash.h
index cee446c59497c6..4829d2367eda87 100644
--- a/include/crypto/hash.h
+++ b/include/crypto/hash.h
@@ -855,6 +855,25 @@ int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key,
 int crypto_shash_digest(struct shash_desc *desc, const u8 *data,
 			unsigned int len, u8 *out);
 
+/**
+ * crypto_shash_tfm_digest() - calculate message digest for buffer
+ * @tfm: hash transformation object
+ * @data: see crypto_shash_update()
+ * @len: see crypto_shash_update()
+ * @out: see crypto_shash_final()
+ *
+ * This is a simplified version of crypto_shash_digest() for users who don't
+ * want to allocate their own hash descriptor (shash_desc).  Instead,
+ * crypto_shash_tfm_digest() takes a hash transformation object (crypto_shash)
+ * directly, and it allocates a hash descriptor on the stack internally.
+ * Note that this stack allocation may be fairly large.
+ *
+ * Context: Any context.
+ * Return: 0 on success; < 0 if an error occurred.
+ */
+int crypto_shash_tfm_digest(struct crypto_shash *tfm, const u8 *data,
+			    unsigned int len, u8 *out);
+
 /**
  * crypto_shash_export() - extract operational state for message digest
  * @desc: reference to the operational state handle whose state is exported
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 15/20] nfsd: use crypto_shash_tfm_digest()
  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 ` Eric Biggers
  2020-05-04 19:09   ` J. Bruce Fields
  2020-05-02  6:44 ` [PATCH 00/20] crypto: introduce crypto_shash_tfm_digest() Marcel Holtmann
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Eric Biggers @ 2020-05-02  5:31 UTC (permalink / raw)
  To: linux-crypto; +Cc: linux-nfs

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>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 00/20] crypto: introduce crypto_shash_tfm_digest()
  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 15/20] nfsd: use crypto_shash_tfm_digest() Eric Biggers
@ 2020-05-02  6:44 ` Marcel Holtmann
  2020-05-03 16:13 ` Ard Biesheuvel
  2020-05-08  6:07 ` Herbert Xu
  4 siblings, 0 replies; 7+ messages in thread
From: Marcel Holtmann @ 2020-05-02  6:44 UTC (permalink / raw)
  To: Eric Biggers
  Cc: linux-crypto, Cheng-Yi Chiang, ecryptfs, Enric Balletbo i Serra,
	Gilad Ben-Yossef, Guenter Roeck, Jesper Nilsson, Kamil Konieczny,
	keyrings, Krzysztof Kozlowski, Krzysztof Opasiak, Lars Persson,
	linux-bluetooth, linux-mtd, linux-nfs, linux-sctp, Robert Baldyga,
	Tom Lendacky, Vladimir Zapolskiy, Zaibo Xu

Hi Eric,

> This series introduces a helper function crypto_shash_tfm_digest() which
> replaces the following common pattern:
> 
> 	{
> 		SHASH_DESC_ON_STACK(desc, tfm);
> 		int err;
> 
> 		desc->tfm = tfm;
> 
> 		err = crypto_shash_digest(desc, data, len, out);
> 
> 		shash_desc_zero(desc);
> 	}
> 
> with:
> 
> 	err = crypto_shash_tfm_digest(tfm, data, len, out);
> 
> Patch 1 introduces this helper function, and patches 2-20 convert all
> relevant users to use it.
> 
> IMO, it would be easiest to take all these patches through the crypto
> tree.  But taking just the "crypto:" ones and then me trying to get the
> rest merged later via subsystem trees is also an option.

I am fine if you take the net/bluetooth/smp.c change through the crypto tree.

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 00/20] crypto: introduce crypto_shash_tfm_digest()
  2020-05-02  5:31 [PATCH 00/20] crypto: introduce crypto_shash_tfm_digest() Eric Biggers
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2020-05-03 16:13 UTC (permalink / raw)
  To: Eric Biggers
  Cc: Linux Crypto Mailing List, Cheng-Yi Chiang, ecryptfs,
	Enric Balletbo i Serra, Gilad Ben-Yossef, Guenter Roeck,
	Jesper Nilsson, Kamil Konieczny, keyrings, Krzysztof Kozlowski,
	Krzysztof Opasiak, Lars Persson, linux-bluetooth, linux-mtd,
	linux-nfs, linux-sctp, Robert Baldyga, Tom Lendacky,
	Vladimir Zapolskiy, Zaibo Xu

On Sat, 2 May 2020 at 07:33, Eric Biggers <ebiggers@kernel.org> wrote:
>
> This series introduces a helper function crypto_shash_tfm_digest() which
> replaces the following common pattern:
>
>         {
>                 SHASH_DESC_ON_STACK(desc, tfm);
>                 int err;
>
>                 desc->tfm = tfm;
>
>                 err = crypto_shash_digest(desc, data, len, out);
>
>                 shash_desc_zero(desc);
>         }
>
> with:
>
>         err = crypto_shash_tfm_digest(tfm, data, len, out);
>
> Patch 1 introduces this helper function, and patches 2-20 convert all
> relevant users to use it.
>
> IMO, it would be easiest to take all these patches through the crypto
> tree.  But taking just the "crypto:" ones and then me trying to get the
> rest merged later via subsystem trees is also an option.
>
> Eric Biggers (20):
>   crypto: hash - introduce crypto_shash_tfm_digest()
>   crypto: arm64/aes-glue - use crypto_shash_tfm_digest()
>   crypto: essiv - use crypto_shash_tfm_digest()
>   crypto: artpec6 - use crypto_shash_tfm_digest()
>   crypto: ccp - use crypto_shash_tfm_digest()
>   crypto: ccree - use crypto_shash_tfm_digest()
>   crypto: hisilicon/sec2 - use crypto_shash_tfm_digest()
>   crypto: mediatek - use crypto_shash_tfm_digest()
>   crypto: n2 - use crypto_shash_tfm_digest()
>   crypto: omap-sham - use crypto_shash_tfm_digest()
>   crypto: s5p-sss - use crypto_shash_tfm_digest()
>   nfc: s3fwrn5: use crypto_shash_tfm_digest()
>   fscrypt: use crypto_shash_tfm_digest()
>   ecryptfs: use crypto_shash_tfm_digest()
>   nfsd: use crypto_shash_tfm_digest()
>   ubifs: use crypto_shash_tfm_digest()
>   Bluetooth: use crypto_shash_tfm_digest()
>   sctp: use crypto_shash_tfm_digest()
>   KEYS: encrypted: use crypto_shash_tfm_digest()
>   ASoC: cros_ec_codec: use crypto_shash_tfm_digest()
>

For the series,

Acked-by: Ard Biesheuvel <ardb@kernel.org>


>  arch/arm64/crypto/aes-glue.c               |  4 +--
>  crypto/essiv.c                             |  4 +--
>  crypto/shash.c                             | 16 +++++++++
>  drivers/crypto/axis/artpec6_crypto.c       | 10 ++----
>  drivers/crypto/ccp/ccp-crypto-sha.c        |  9 ++---
>  drivers/crypto/ccree/cc_cipher.c           |  9 ++---
>  drivers/crypto/hisilicon/sec2/sec_crypto.c |  5 ++-
>  drivers/crypto/mediatek/mtk-sha.c          |  7 ++--
>  drivers/crypto/n2_core.c                   |  7 ++--
>  drivers/crypto/omap-sham.c                 | 20 +++--------
>  drivers/crypto/s5p-sss.c                   | 39 ++++------------------
>  drivers/nfc/s3fwrn5/firmware.c             | 10 +-----
>  fs/crypto/fname.c                          |  7 +---
>  fs/crypto/hkdf.c                           |  6 +---
>  fs/ecryptfs/crypto.c                       | 17 +---------
>  fs/nfsd/nfs4recover.c                      | 26 ++++-----------
>  fs/ubifs/auth.c                            | 20 ++---------
>  fs/ubifs/master.c                          |  9 ++---
>  fs/ubifs/replay.c                          | 14 ++------
>  include/crypto/hash.h                      | 19 +++++++++++
>  net/bluetooth/smp.c                        |  6 +---
>  net/sctp/auth.c                            | 10 ++----
>  net/sctp/sm_make_chunk.c                   | 23 +++++--------
>  security/keys/encrypted-keys/encrypted.c   | 18 ++--------
>  sound/soc/codecs/cros_ec_codec.c           |  9 +----
>  25 files changed, 95 insertions(+), 229 deletions(-)
>
> --
> 2.26.2
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 15/20] nfsd: use crypto_shash_tfm_digest()
  2020-05-02  5:31 ` [PATCH 15/20] nfsd: use crypto_shash_tfm_digest() Eric Biggers
@ 2020-05-04 19:09   ` J. Bruce Fields
  0 siblings, 0 replies; 7+ messages in thread
From: J. Bruce Fields @ 2020-05-04 19:09 UTC (permalink / raw)
  To: Eric Biggers; +Cc: linux-crypto, linux-nfs

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 00/20] crypto: introduce crypto_shash_tfm_digest()
  2020-05-02  5:31 [PATCH 00/20] crypto: introduce crypto_shash_tfm_digest() Eric Biggers
                   ` (3 preceding siblings ...)
  2020-05-03 16:13 ` Ard Biesheuvel
@ 2020-05-08  6:07 ` Herbert Xu
  4 siblings, 0 replies; 7+ messages in thread
From: Herbert Xu @ 2020-05-08  6:07 UTC (permalink / raw)
  To: Eric Biggers
  Cc: linux-crypto, cychiang, ecryptfs, enric.balletbo, gilad, groeck,
	jesper.nilsson, k.konieczny, keyrings, krzk, k.opasiak,
	lars.persson, linux-bluetooth, linux-mtd, linux-nfs, linux-sctp,
	r.baldyga, thomas.lendacky, vz, xuzaibo

Eric Biggers <ebiggers@kernel.org> wrote:
> This series introduces a helper function crypto_shash_tfm_digest() which
> replaces the following common pattern:
> 
>        {
>                SHASH_DESC_ON_STACK(desc, tfm);
>                int err;
> 
>                desc->tfm = tfm;
> 
>                err = crypto_shash_digest(desc, data, len, out);
> 
>                shash_desc_zero(desc);
>        }
> 
> with:
> 
>        err = crypto_shash_tfm_digest(tfm, data, len, out);
> 
> Patch 1 introduces this helper function, and patches 2-20 convert all
> relevant users to use it.
> 
> IMO, it would be easiest to take all these patches through the crypto
> tree.  But taking just the "crypto:" ones and then me trying to get the
> rest merged later via subsystem trees is also an option.
> 
> Eric Biggers (20):
>  crypto: hash - introduce crypto_shash_tfm_digest()
>  crypto: arm64/aes-glue - use crypto_shash_tfm_digest()
>  crypto: essiv - use crypto_shash_tfm_digest()
>  crypto: artpec6 - use crypto_shash_tfm_digest()
>  crypto: ccp - use crypto_shash_tfm_digest()
>  crypto: ccree - use crypto_shash_tfm_digest()
>  crypto: hisilicon/sec2 - use crypto_shash_tfm_digest()
>  crypto: mediatek - use crypto_shash_tfm_digest()
>  crypto: n2 - use crypto_shash_tfm_digest()
>  crypto: omap-sham - use crypto_shash_tfm_digest()
>  crypto: s5p-sss - use crypto_shash_tfm_digest()
>  nfc: s3fwrn5: use crypto_shash_tfm_digest()
>  fscrypt: use crypto_shash_tfm_digest()
>  ecryptfs: use crypto_shash_tfm_digest()
>  nfsd: use crypto_shash_tfm_digest()
>  ubifs: use crypto_shash_tfm_digest()
>  Bluetooth: use crypto_shash_tfm_digest()
>  sctp: use crypto_shash_tfm_digest()
>  KEYS: encrypted: use crypto_shash_tfm_digest()
>  ASoC: cros_ec_codec: use crypto_shash_tfm_digest()
> 
> arch/arm64/crypto/aes-glue.c               |  4 +--
> crypto/essiv.c                             |  4 +--
> crypto/shash.c                             | 16 +++++++++
> drivers/crypto/axis/artpec6_crypto.c       | 10 ++----
> drivers/crypto/ccp/ccp-crypto-sha.c        |  9 ++---
> drivers/crypto/ccree/cc_cipher.c           |  9 ++---
> drivers/crypto/hisilicon/sec2/sec_crypto.c |  5 ++-
> drivers/crypto/mediatek/mtk-sha.c          |  7 ++--
> drivers/crypto/n2_core.c                   |  7 ++--
> drivers/crypto/omap-sham.c                 | 20 +++--------
> drivers/crypto/s5p-sss.c                   | 39 ++++------------------
> drivers/nfc/s3fwrn5/firmware.c             | 10 +-----
> fs/crypto/fname.c                          |  7 +---
> fs/crypto/hkdf.c                           |  6 +---
> fs/ecryptfs/crypto.c                       | 17 +---------
> fs/nfsd/nfs4recover.c                      | 26 ++++-----------
> fs/ubifs/auth.c                            | 20 ++---------
> fs/ubifs/master.c                          |  9 ++---
> fs/ubifs/replay.c                          | 14 ++------
> include/crypto/hash.h                      | 19 +++++++++++
> net/bluetooth/smp.c                        |  6 +---
> net/sctp/auth.c                            | 10 ++----
> net/sctp/sm_make_chunk.c                   | 23 +++++--------
> security/keys/encrypted-keys/encrypted.c   | 18 ++--------
> sound/soc/codecs/cros_ec_codec.c           |  9 +----
> 25 files changed, 95 insertions(+), 229 deletions(-)

All applied.  Thanks.
-- 
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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-05-08  6:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 15/20] nfsd: use crypto_shash_tfm_digest() Eric Biggers
2020-05-04 19:09   ` J. Bruce Fields
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox