Skip to content

Commit

Permalink
crypto: ccree - unmap buffer before copying IV
Browse files Browse the repository at this point in the history
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: Gilad Ben-Yossef <gilad@benyossef.com>
Fixes: 00904aa ("crypto: ccree - fix iv handling")
Cc: <stable@vger.kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Gilad Ben-Yossef authored and Herbert Xu committed Jan 25, 2019
1 parent 1ffbe13 commit c139c72
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/crypto/ccree/cc_cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 len;

cc_unmap_cipher_request(dev, req_ctx, ivsize, src, dst);

switch (ctx_p->cipher_mode) {
case DRV_CIPHER_CBC:
/*
Expand Down Expand Up @@ -681,7 +683,6 @@ static void cc_cipher_complete(struct device *dev, void *cc_req, int err)
break;
}

cc_unmap_cipher_request(dev, req_ctx, ivsize, src, dst);
kzfree(req_ctx->iv);

skcipher_request_complete(req, err);
Expand Down

0 comments on commit c139c72

Please sign in to comment.