[<prev] [next>] [day] [month] [year] [list]
Message-ID: <6327d472-b4d5-4678-b54c-9808a68e3504@stanley.mountain>
Date: Thu, 15 Aug 2024 00:11:58 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Pavitrakumar M <pavitrakumarm@...avyalabs.com>
Cc: Herbert Xu <herbert@...dor.apana.org.au>,
"David S. Miller" <davem@...emloft.net>,
Bhoomika K <bhoomikak@...avyalabs.com>,
Ruud Derwig <Ruud.Derwig@...opsys.com>,
linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 2/3] crypto: spacc - Fix off by one in spacc_isenabled()
The spacc->config.modes[] array has CRYPTO_MODE_LAST number of elements
so this > comparison should be >= to prevent an out of bounds access.
Fixes: c8981d9230d8 ("crypto: spacc - Add SPAcc Skcipher support")
Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
---
The CRYPTO_MODE_LAST variable is poorly named. Based on the name you
would expect it to be the last valid value but it's not. (I'm not
a huge fan of code which uses the last valid value instead of the
size personally, but the names should match).
drivers/crypto/dwc-spacc/spacc_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/dwc-spacc/spacc_core.c b/drivers/crypto/dwc-spacc/spacc_core.c
index e3380528e82b..b7630f559973 100644
--- a/drivers/crypto/dwc-spacc/spacc_core.c
+++ b/drivers/crypto/dwc-spacc/spacc_core.c
@@ -1295,7 +1295,7 @@ int spacc_isenabled(struct spacc_device *spacc, int mode, int keysize)
{
int x;
- if (mode < 0 || mode > CRYPTO_MODE_LAST)
+ if (mode < 0 || mode >= CRYPTO_MODE_LAST)
return 0;
if (mode == CRYPTO_MODE_NULL ||
--
2.43.0
Powered by blists - more mailing lists