diff options
author | Corentin Labbe <clabbe.montjoie@gmail.com> | 2019-04-18 11:17:34 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-05-31 16:48:16 +0300 |
commit | 2ed24236b933603bc25f843c5da9e48b96dd98c4 (patch) | |
tree | 58c072e8d83af46be299e5d517b354dd56b7196c /drivers/crypto | |
parent | 2f3201b23b69bbae2f9fec18648b45df5cd93960 (diff) | |
download | linux-2ed24236b933603bc25f843c5da9e48b96dd98c4.tar.xz |
crypto: sun4i-ss - Fix invalid calculation of hash end
[ Upstream commit f87391558acf816b48f325a493d81d45dec40da0 ]
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: 6298e948215f ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/sunxi-ss/sun4i-ss-hash.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c index 0de2f62d51ff..ec16ec2e284d 100644 --- a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c +++ b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c @@ -250,7 +250,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 == 0 then DMA */ |