[PATCH] crypto: qat - (qat_4xxx) fix off by one in uof_get_name()

Dan Carpenter posted 1 patch 2 months ago
drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] crypto: qat - (qat_4xxx) fix off by one in uof_get_name()
Posted by Dan Carpenter 2 months ago
The fw_objs[] array has "num_objs" elements so the > needs to be >= to
prevent an out of bounds read.

Fixes: 10484c647af6 ("crypto: qat - refactor fw config logic for 4xxx")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c b/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c
index 9fd7ec53b9f3..bbd92c017c28 100644
--- a/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c
+++ b/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c
@@ -334,7 +334,7 @@ static const char *uof_get_name(struct adf_accel_dev *accel_dev, u32 obj_num,
 	else
 		id = -EINVAL;
 
-	if (id < 0 || id > num_objs)
+	if (id < 0 || id >= num_objs)
 		return NULL;
 
 	return fw_objs[id];
-- 
2.45.2
Re: [PATCH] crypto: qat - (qat_4xxx) fix off by one in uof_get_name()
Posted by Herbert Xu 1 month, 3 weeks ago
On Sat, Sep 28, 2024 at 01:05:08PM +0300, Dan Carpenter wrote:
> The fw_objs[] array has "num_objs" elements so the > needs to be >= to
> prevent an out of bounds read.
> 
> Fixes: 10484c647af6 ("crypto: qat - refactor fw config logic for 4xxx")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH] crypto: qat - (qat_4xxx) fix off by one in uof_get_name()
Posted by Cabiddu, Giovanni 1 month, 4 weeks ago
On Sat, Sep 28, 2024 at 01:05:08PM +0300, Dan Carpenter wrote:
> The fw_objs[] array has "num_objs" elements so the > needs to be >= to
> prevent an out of bounds read.
> 
> Fixes: 10484c647af6 ("crypto: qat - refactor fw config logic for 4xxx")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>