From: Thara Gopinath Date: Thu, 19 Nov 2020 15:52:31 +0000 (-0500) Subject: crypto: qce - Fix SHA result buffer corruption issues X-Git-Tag: v5.15~2056^2~36 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1148a9654b5a69611d33e14719251c6ec20f5f2c;p=platform%2Fkernel%2Flinux-starfive.git crypto: qce - Fix SHA result buffer corruption issues Partial hash was being copied into the final result buffer without the entire message block processed. Depending on how the end user processes this result buffer, errors vary from result buffer corruption to result buffer poisoing. Fix this issue by ensuring that only the final hash value is copied into the result buffer. Reviewed-by: Bjorn Andersson Signed-off-by: Thara Gopinath Signed-off-by: Herbert Xu --- diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index 87be96a0..61c418c 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -48,7 +48,7 @@ static void qce_ahash_done(void *data) dma_unmap_sg(qce->dev, &rctx->result_sg, 1, DMA_FROM_DEVICE); memcpy(rctx->digest, result->auth_iv, digestsize); - if (req->result) + if (req->result && rctx->last_blk) memcpy(req->result, result->auth_iv, digestsize); rctx->byte_count[0] = cpu_to_be32(result->auth_byte_count[0]);