Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936323AbcLMRWm (ORCPT ); Tue, 13 Dec 2016 12:22:42 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:57158 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936214AbcLMRQi (ORCPT ); Tue, 13 Dec 2016 12:16:38 -0500 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Romain Perier , Herbert Xu Subject: [PATCH 4.8 23/33] crypto: marvell - Dont corrupt state of an STD req for re-stepped ahash Date: Tue, 13 Dec 2016 09:16:24 -0800 Message-Id: <20161213171535.606291928@linuxfoundation.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161213171534.171564506@linuxfoundation.org> References: <20161213171534.171564506@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1603 Lines: 43 4.8-stable review patch. If anyone has any objections, please let me know. ------------------ From: Romain Perier commit 9e5f7a149e00d211177f6de8be427ebc72a1c363 upstream. mv_cesa_hash_std_step() copies the creq->state into the SRAM at each step, but this is only required on the first one. By doing that, we overwrite the engine state, and get erroneous results when the crypto request is split in several chunks to fit in the internal SRAM. This commit changes the function to copy the state only on the first step. Fixes: commit 2786cee8e50b ("crypto: marvell - Move SRAM I/O op...") Signed-off-by: Romain Perier Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/marvell/hash.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/crypto/marvell/hash.c +++ b/drivers/crypto/marvell/hash.c @@ -168,9 +168,11 @@ static void mv_cesa_ahash_std_step(struc mv_cesa_adjust_op(engine, &creq->op_tmpl); memcpy_toio(engine->sram, &creq->op_tmpl, sizeof(creq->op_tmpl)); - digsize = crypto_ahash_digestsize(crypto_ahash_reqtfm(req)); - for (i = 0; i < digsize / 4; i++) - writel_relaxed(creq->state[i], engine->regs + CESA_IVDIG(i)); + if (!sreq->offset) { + digsize = crypto_ahash_digestsize(crypto_ahash_reqtfm(req)); + for (i = 0; i < digsize / 4; i++) + writel_relaxed(creq->state[i], engine->regs + CESA_IVDIG(i)); + } if (creq->cache_ptr) memcpy_toio(engine->sram + CESA_SA_DATA_SRAM_OFFSET,