crypto: caam - fix output sequence contiguity check
authorTudor Ambarus <tudor.ambarus@freescale.com>
Fri, 24 Oct 2014 15:13:37 +0000 (18:13 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 6 Nov 2014 15:15:00 +0000 (23:15 +0800)
This patch fixes the assumption that output sequence is not contiguous
when input sequence is not contiguous and in-place encryption is done.
Output sequence does not need to be contiguous with associated data.

Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/caamalg.c

index c17154c3203142ba60ceabc9cc3b80a1fc025084..36434d9eefad18c8f1ab293d1ddcad9700845e7b 100644 (file)
@@ -2185,7 +2185,8 @@ static struct aead_edesc *aead_giv_edesc_alloc(struct aead_givcrypt_request
                assoc_nents = assoc_nents ? : 1;
                src_nents = src_nents ? : 1;
                sec4_sg_len += assoc_nents + 1 + src_nents;
-               if (likely(req->src == req->dst))
+               if (req->src == req->dst &&
+                   (src_nents || iv_dma + ivsize != sg_dma_address(req->src)))
                        contig &= ~GIV_DST_CONTIG;
        }