2022-06-10 18:28:53

by Alexey Khoroshilov

[permalink] [raw]
Subject: [PATCH] crypto: sun8i-ss - fix infinite loop in sun8i_ss_setup_ivs()

There is no i decrement in while (i >= 0) loop.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Alexey Khoroshilov <[email protected]>
Fixes: 359e893e8af4 ("crypto: sun8i-ss - rework handling of IV")
---
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
index 5bb950182026..910d6751644c 100644
--- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
+++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
@@ -170,6 +170,7 @@ static int sun8i_ss_setup_ivs(struct skcipher_request *areq)
while (i >= 0) {
dma_unmap_single(ss->dev, rctx->p_iv[i], ivsize, DMA_TO_DEVICE);
memzero_explicit(sf->iv[i], ivsize);
+ i--;
}
return err;
}
--
2.7.4


2022-06-11 09:35:00

by Corentin Labbe

[permalink] [raw]
Subject: Re: [PATCH] crypto: sun8i-ss - fix infinite loop in sun8i_ss_setup_ivs()

Le Fri, Jun 10, 2022 at 09:27:15PM +0300, Alexey Khoroshilov a ?crit :
> There is no i decrement in while (i >= 0) loop.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Alexey Khoroshilov <[email protected]>
> Fixes: 359e893e8af4 ("crypto: sun8i-ss - rework handling of IV")
> ---
> drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
> index 5bb950182026..910d6751644c 100644
> --- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
> +++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
> @@ -170,6 +170,7 @@ static int sun8i_ss_setup_ivs(struct skcipher_request *areq)
> while (i >= 0) {
> dma_unmap_single(ss->dev, rctx->p_iv[i], ivsize, DMA_TO_DEVICE);
> memzero_explicit(sf->iv[i], ivsize);
> + i--;
> }
> return err;
> }
> --
> 2.7.4
>

Acked-by: Corentin Labbe <[email protected]>
Tested-by: Corentin Labbe <[email protected]>

Thanks

2022-06-17 09:35:01

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: sun8i-ss - fix infinite loop in sun8i_ss_setup_ivs()

On Fri, Jun 10, 2022 at 09:27:15PM +0300, Alexey Khoroshilov wrote:
> There is no i decrement in while (i >= 0) loop.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Alexey Khoroshilov <[email protected]>
> Fixes: 359e893e8af4 ("crypto: sun8i-ss - rework handling of IV")
> ---
> drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c | 1 +
> 1 file changed, 1 insertion(+)

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