mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-06 05:06:29 +00:00
crypto: sun8i-ss - do not fallback if cryptlen is less than sg length
The sg length could be more than remaining data on it. So check the length requirement against the minimum between those two values. Signed-off-by: Corentin Labbe <clabbe@baylibre.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
801b7d572c
commit
2e5545acf6
@ -28,6 +28,7 @@ static bool sun8i_ss_need_fallback(struct skcipher_request *areq)
|
||||
struct scatterlist *in_sg = areq->src;
|
||||
struct scatterlist *out_sg = areq->dst;
|
||||
struct scatterlist *sg;
|
||||
unsigned int todo, len;
|
||||
|
||||
if (areq->cryptlen == 0 || areq->cryptlen % 16) {
|
||||
algt->stat_fb_len++;
|
||||
@ -40,13 +41,11 @@ static bool sun8i_ss_need_fallback(struct skcipher_request *areq)
|
||||
return true;
|
||||
}
|
||||
|
||||
len = areq->cryptlen;
|
||||
sg = areq->src;
|
||||
while (sg) {
|
||||
if ((sg->length % 16) != 0) {
|
||||
algt->stat_fb_sglen++;
|
||||
return true;
|
||||
}
|
||||
if ((sg_dma_len(sg) % 16) != 0) {
|
||||
todo = min(len, sg->length);
|
||||
if ((todo % 16) != 0) {
|
||||
algt->stat_fb_sglen++;
|
||||
return true;
|
||||
}
|
||||
@ -54,15 +53,14 @@ static bool sun8i_ss_need_fallback(struct skcipher_request *areq)
|
||||
algt->stat_fb_align++;
|
||||
return true;
|
||||
}
|
||||
len -= todo;
|
||||
sg = sg_next(sg);
|
||||
}
|
||||
len = areq->cryptlen;
|
||||
sg = areq->dst;
|
||||
while (sg) {
|
||||
if ((sg->length % 16) != 0) {
|
||||
algt->stat_fb_sglen++;
|
||||
return true;
|
||||
}
|
||||
if ((sg_dma_len(sg) % 16) != 0) {
|
||||
todo = min(len, sg->length);
|
||||
if ((todo % 16) != 0) {
|
||||
algt->stat_fb_sglen++;
|
||||
return true;
|
||||
}
|
||||
@ -70,6 +68,7 @@ static bool sun8i_ss_need_fallback(struct skcipher_request *areq)
|
||||
algt->stat_fb_align++;
|
||||
return true;
|
||||
}
|
||||
len -= todo;
|
||||
sg = sg_next(sg);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user