Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1472591

[PATCH 2/4] crypto: qce: Avoid repeat hash finalization

From Iaroslav Gridin <voker57@gmail.com>
Newsgroups linux.kernel
Subject [PATCH 2/4] crypto: qce: Avoid repeat hash finalization
Date 2016-08-30 18:00 +0200
Message-ID <sbTCa-6Nf-33@gated-at.bofh.it> (permalink)
References <sbTC9-6Nf-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Voker57 <voker57@gmail.com>

Calling QCE finalization when hash have already been finalized causes
a lockup. Avoid it by introducing finalized flag.
Signed-off-by: Iaroslav Gridin <voker57@gmail.com>
---
 drivers/crypto/qce/sha.c | 6 ++++++
 drivers/crypto/qce/sha.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c
index a124bb9..a068d39 100644
--- a/drivers/crypto/qce/sha.c
+++ b/drivers/crypto/qce/sha.c
@@ -139,6 +139,7 @@ static int qce_ahash_init(struct ahash_request *req)
 	rctx->first_blk = true;
 	rctx->last_blk = false;
 	rctx->flags = tmpl->alg_flags;
+	rctx->finalized = false;
 	memcpy(rctx->digest, std_iv, sizeof(rctx->digest));
 
 	return 0;
@@ -314,7 +315,12 @@ static int qce_ahash_final(struct ahash_request *req)
 	if (!rctx->buflen)
 		return 0;
 
+	/* If hash is already been finalized, don't do anything */
+	if (rctx->finalized)
+		return 0;
+
 	rctx->last_blk = true;
+	rctx->finalized = true;
 
 	rctx->src_orig = req->src;
 	rctx->nbytes_orig = req->nbytes;
diff --git a/drivers/crypto/qce/sha.h b/drivers/crypto/qce/sha.h
index 236bb5e9..b24568f 100644
--- a/drivers/crypto/qce/sha.h
+++ b/drivers/crypto/qce/sha.h
@@ -59,6 +59,7 @@ struct qce_sha_reqctx {
 	u64 count;
 	bool first_blk;
 	bool last_blk;
+	bool finalized;
 	struct scatterlist sg[2];
 	u8 *authkey;
 	unsigned int authklen;
-- 
2.9.3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

(none) Iaroslav Gridin <voker57@gmail.com> - 2016-08-30 18:00 +0200
  [PATCH 2/4] crypto: qce: Avoid repeat hash finalization Iaroslav Gridin <voker57@gmail.com> - 2016-08-30 18:00 +0200
  [PATCH 3/4] crypto: qce: Ensure QCE receives no zero-sized updates Iaroslav Gridin <voker57@gmail.com> - 2016-08-30 18:00 +0200

csiph-web