crypto/ccp - Fill the result buffer only on digest, finup, and final ops
diff mbox

Message ID 152044426211.9969.5499799691786404440.stgit@sosxen2.amd.com
State Accepted
Delegated to: Herbert Xu
Headers show

Commit Message

Gary R Hook March 7, 2018, 5:37 p.m. UTC
Any change to the result buffer should only happen on final, finup
and digest operations. Changes to the buffer for update, import, export,
etc, are not allowed.

Fixes: 66d7b9f6175e ("crypto: testmgr - test misuse of result in ahash")
Signed-off-by: Gary R Hook <gary.hook@amd.com>
Cc: <stable@vger.kernel.org>
---
 0 files changed

Comments

Herbert Xu March 9, 2018, 3:20 p.m. UTC | #1
On Wed, Mar 07, 2018 at 11:37:42AM -0600, Gary R Hook wrote:
> Any change to the result buffer should only happen on final, finup
> and digest operations. Changes to the buffer for update, import, export,
> etc, are not allowed.
> 
> Fixes: 66d7b9f6175e ("crypto: testmgr - test misuse of result in ahash")
> Signed-off-by: Gary R Hook <gary.hook@amd.com>
> Cc: <stable@vger.kernel.org>

Patch applied.  Thanks.

Patch
diff mbox

diff --git a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
index 60fc0fa26fd3..26687f318de6 100644
--- a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
+++ b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
@@ -46,7 +46,7 @@  static int ccp_aes_cmac_complete(struct crypto_async_request *async_req,
 	}
 
 	/* Update result area if supplied */
-	if (req->result)
+	if (req->result && rctx->final)
 		memcpy(req->result, rctx->iv, digest_size);
 
 e_free:
diff --git a/drivers/crypto/ccp/ccp-crypto-sha.c b/drivers/crypto/ccp/ccp-crypto-sha.c
index 8b9b16d433f7..871c9628a2ee 100644
--- a/drivers/crypto/ccp/ccp-crypto-sha.c
+++ b/drivers/crypto/ccp/ccp-crypto-sha.c
@@ -47,7 +47,7 @@  static int ccp_sha_complete(struct crypto_async_request *async_req, int ret)
 	}
 
 	/* Update result area if supplied */
-	if (req->result)
+	if (req->result && rctx->final)
 		memcpy(req->result, rctx->ctx, digest_size);
 
 e_free: