Commit c139c72e authored by Gilad Ben-Yossef's avatar Gilad Ben-Yossef Committed by Herbert Xu

crypto: ccree - unmap buffer before copying IV

We were copying the last ciphertext block into the IV field
for CBC before removing the DMA mapping of the output buffer
with the result of the buffer sometime being out-of-sync cache
wise and were getting intermittent cases of bad output IV.

Fix it by moving the DMA buffer unmapping before the copy.
Signed-off-by: default avatarGilad Ben-Yossef <gilad@benyossef.com>
Fixes: 00904aa0 ("crypto: ccree - fix iv handling")
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 1ffbe134
...@@ -652,6 +652,8 @@ static void cc_cipher_complete(struct device *dev, void *cc_req, int err) ...@@ -652,6 +652,8 @@ static void cc_cipher_complete(struct device *dev, void *cc_req, int err)
unsigned int ivsize = crypto_skcipher_ivsize(sk_tfm); unsigned int ivsize = crypto_skcipher_ivsize(sk_tfm);
unsigned int len; unsigned int len;
cc_unmap_cipher_request(dev, req_ctx, ivsize, src, dst);
switch (ctx_p->cipher_mode) { switch (ctx_p->cipher_mode) {
case DRV_CIPHER_CBC: case DRV_CIPHER_CBC:
/* /*
...@@ -681,7 +683,6 @@ static void cc_cipher_complete(struct device *dev, void *cc_req, int err) ...@@ -681,7 +683,6 @@ static void cc_cipher_complete(struct device *dev, void *cc_req, int err)
break; break;
} }
cc_unmap_cipher_request(dev, req_ctx, ivsize, src, dst);
kzfree(req_ctx->iv); kzfree(req_ctx->iv);
skcipher_request_complete(req, err); skcipher_request_complete(req, err);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment