2014-10-23 13:55:25

by Tudor Ambarus

[permalink] [raw]
Subject: [PATCH] caam: caamalg - fix output sequence contiguity check

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 <[email protected]>
---
drivers/crypto/caam/caamalg.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
index a80ea85..922a3f5 100644
--- a/drivers/crypto/caam/caamalg.c
+++ b/drivers/crypto/caam/caamalg.c
@@ -1530,7 +1530,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;
}
sec4_sg_len += dst_nents;
--
1.8.3.1


2014-10-24 15:14:23

by Tudor Ambarus

[permalink] [raw]
Subject: [PATCH v2] crypto: caam - fix output sequence contiguity check

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 <[email protected]>
---
Substitute 'caam: caamalg' with 'crypto: caam' in commit message.

drivers/crypto/caam/caamalg.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
index c17154c..36434d9 100644
--- a/drivers/crypto/caam/caamalg.c
+++ b/drivers/crypto/caam/caamalg.c
@@ -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;
}

--
1.8.3.1

2014-11-06 15:16:50

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH v2] crypto: caam - fix output sequence contiguity check

On Fri, Oct 24, 2014 at 06:13:37PM +0300, Tudor Ambarus wrote:
> 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 <[email protected]>

Applied.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt