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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230806170604.16143-6-james@equiv.tech>
Date:   Sun,  6 Aug 2023 10:05:57 -0700
From:   James Seo <james@...iv.tech>
To:     Sathya Prakash <sathya.prakash@...adcom.com>,
        Sreekanth Reddy <sreekanth.reddy@...adcom.com>,
        Suganath Prabu Subramani 
        <suganath-prabu.subramani@...adcom.com>
Cc:     James Seo <james@...iv.tech>,
        "James E.J. Bottomley" <jejb@...ux.ibm.com>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        Kees Cook <keescook@...omium.org>,
        "Gustavo A. R. Silva" <gustavoars@...nel.org>,
        MPT-FusionLinux.pdl@...adcom.com, linux-scsi@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH v2 05/12] scsi: mpt3sas: Make MPI2_CONFIG_PAGE_SASIOUNIT_1::PhyData[] a flexible array

This terminal 1-length variable array can be directly converted into
a C99 flexible array member.

As all users of MPI2_CONFIG_PAGE_SASIOUNIT_1 (Mpi2SasIOUnitPage1_t)
either calculate its size without depending on its sizeof() or do not
use PhyData[], no further source changes are required:

- mpt3sas_config.c:mpt3sas_config_get_sas_iounit_pg1() fetches a
  Mpi2SasIOUnitPage1_t into a caller-provided buffer, and may fetch
  and write PhyData[] into that buffer depending on its sz argument.
  Its callers:

  - mpt3sas_base.c:_base_assign_fw_reported_qd() passes
    sizeof(Mpi2SasIOUnitPage1_t) as sz, but does not use PhyData[].

  - mpt3sas_base.c:mpt3sas_base_update_missing_delay(),
    mpt3sas_scsih.c:_scsih_sas_host_add(),
    mpt3sas_transport.c:_transport_phy_enable(), and
    mpt3sas_transport.c:_transport_phy_speed() all calculate sz
    independently of sizeof(Mpi2SasIOUnitPage1_t) and allocate a
    suitable buffer before calling mpt3sas_config_get_sas_iounit_pg1()
    and using PhyData[].

- mpt3sas_config.c:mpt3sas_config_set_sas_iounit_pg1() writes the
  contents of a caller-provided buffer to the adapter, with the size
  of the write depending on its sz argument. Its callers:

  - mpt3sas_base.c:mpt3sas_base_update_missing_delay(),
    mpt3sas_transport.c:_transport_phy_enable(), and
    mpt3sas_transport.c:_transport_phy_speed() have all previously
    called mpt3sas_config_get_sas_iounit_pg1() to obtain a
    Mpi2SasIOUnitPage1_t, and are merely writing back this same
    struct with the same previously calculated sz.

Signed-off-by: James Seo <james@...iv.tech>
---
 drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h b/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h
index 07a8d7646b6d..138f31def81d 100644
--- a/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h
+++ b/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h
@@ -2249,12 +2249,9 @@ typedef struct _MPI2_SAS_IO_UNIT1_PHY_DATA {
 	*pMpi2SasIOUnit1PhyData_t;
 
 /*
- *Host code (drivers, BIOS, utilities, etc.) should leave this define set to
- *one and check the value returned for NumPhys at runtime.
+ *Host code (drivers, BIOS, utilities, etc.) should check the value returned
+ *for NumPhys at runtime before using PhyData[].
  */
-#ifndef MPI2_SAS_IOUNIT1_PHY_MAX
-#define MPI2_SAS_IOUNIT1_PHY_MAX        (1)
-#endif
 
 typedef struct _MPI2_CONFIG_PAGE_SASIOUNIT_1 {
 	MPI2_CONFIG_EXTENDED_PAGE_HEADER    Header; /*0x00 */
@@ -2275,7 +2272,7 @@ typedef struct _MPI2_CONFIG_PAGE_SASIOUNIT_1 {
 	U8
 		IODeviceMissingDelay;               /*0x13 */
 	MPI2_SAS_IO_UNIT1_PHY_DATA
-		PhyData[MPI2_SAS_IOUNIT1_PHY_MAX];  /*0x14 */
+		PhyData[];                          /*0x14 */
 } MPI2_CONFIG_PAGE_SASIOUNIT_1,
 	*PTR_MPI2_CONFIG_PAGE_SASIOUNIT_1,
 	Mpi2SasIOUnitPage1_t, *pMpi2SasIOUnitPage1_t;
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ