Skip to content

Commit

Permalink
crypto: sun4i-ss - Fix invalid calculation of hash end
Browse files Browse the repository at this point in the history
When nbytes < 4, end is wronlgy set to a negative value which, due to
uint, is then interpreted to a large value leading to a deadlock in the
following code.

This patch fix this problem.

Fixes: 6298e94 ("crypto: sunxi-ss - Add Allwinner Security System crypto accelerator")
Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Corentin Labbe authored and Herbert Xu committed Apr 25, 2019
1 parent 179930a commit f873915
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/crypto/sunxi-ss/sun4i-ss-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,10 @@ static int sun4i_hash(struct ahash_request *areq)
}
} else {
/* Since we have the flag final, we can go up to modulo 4 */
end = ((areq->nbytes + op->len) / 4) * 4 - op->len;
if (areq->nbytes < 4)
end = 0;
else
end = ((areq->nbytes + op->len) / 4) * 4 - op->len;
}

/* TODO if SGlen % 4 and !op->len then DMA */
Expand Down

0 comments on commit f873915

Please sign in to comment.