lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220427133657.55241-1-huobean@gmail.com>
Date:   Wed, 27 Apr 2022 15:36:57 +0200
From:   Bean Huo <huobean@...il.com>
To:     jejb@...ux.ibm.com, martin.petersen@...cle.com,
        john.garry@...wei.com, chenxiang66@...ilicon.com,
        bvanassche@....org, linux-scsi@...r.kernel.org,
        linux-kernel@...r.kernel.org
Cc:     beanhuo@...ron.com
Subject: [PATCH v1] scsi: libsas: Fix array-bounds warnings

From: Bean Huo <beanhuo@...ron.com>

Use the latest GCC will show below array-bounds warning:

drivers/scsi/libsas/sas_expander.c:1697:39: warning: array subscript ‘struct
smp_resp[0]’ is partly outside array bounds of ‘unsigned char[56]’ [-Warray-bounds]
...
drivers/scsi/libsas/sas_expander.c:1781:20: warning: array subscript ‘struct
smp_resp[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
...
rivers/scsi/libsas/sas_expander.c:1786:39: warning: array subscript ‘struct
smp_resp[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
...
drivers/scsi/libsas/sas_expander.c:476:35: warning: array subscript ‘struct
smp_resp[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
...
drivers/scsi/libsas/sas_expander.c:479:38: warning: array subscript ‘struct
smp_resp[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]

This patch aims to fix these warnings by directly using struct sizes instead of
macro definitions.

Signed-off-by: Bean Huo <beanhuo@...ron.com>
---
 drivers/scsi/libsas/sas_expander.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 260e735d06fa..ac6d9be358c5 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -457,7 +457,7 @@ static int sas_ex_general(struct domain_device *dev)
 	if (!rg_req)
 		return -ENOMEM;
 
-	rg_resp = alloc_smp_resp(RG_RESP_SIZE);
+	rg_resp = alloc_smp_resp(sizeof(struct smp_resp));
 	if (!rg_resp) {
 		kfree(rg_req);
 		return -ENOMEM;
@@ -1688,7 +1688,7 @@ static int sas_get_phy_change_count(struct domain_device *dev,
 	int res;
 	struct smp_resp *disc_resp;
 
-	disc_resp = alloc_smp_resp(DISCOVER_RESP_SIZE);
+	disc_resp = alloc_smp_resp(sizeof(struct smp_resp));
 	if (!disc_resp)
 		return -ENOMEM;
 
@@ -1766,7 +1766,7 @@ static int sas_get_ex_change_count(struct domain_device *dev, int *ecc)
 	if (!rg_req)
 		return -ENOMEM;
 
-	rg_resp = alloc_smp_resp(RG_RESP_SIZE);
+	rg_resp = alloc_smp_resp(sizeof(struct smp_resp));
 	if (!rg_resp) {
 		kfree(rg_req);
 		return -ENOMEM;
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ