scsi: message: fusion: Replace 1-element arrays with flexible arrays
Subsystems (2)
cover scsi: message: fusion: Replace 1-element arrays with flexible arrays
Hi,
Replace all remaining uses of deprecated 1-element "fake" flexible arrays with modern C99 flexible arrays. Add __counted_by annotations at the same time.
Thanks!
-Kees
Kees Cook (6):
scsi: message: fusion: struct _RAID_VOL0_SETTINGS: Replace 1-element
array with flexible array
scsi: message: fusion: struct _CONFIG_PAGE_SAS_IO_UNIT_0: Replace
1-element array with flexible array
scsi: message: fusion: struct _CONFIG_PAGE_RAID_PHYS_DISK_1: Replace
1-element array with flexible array
scsi: message: fusion: struct _CONFIG_PAGE_IOC_2: Replace 1-element
array with flexible array
scsi: message: fusion: struct _CONFIG_PAGE_IOC_3: Replace 1-element
array with flexible array
scsi: message: fusion: struct _CONFIG_PAGE_IOC_4: Replace 1-element
array with flexible array
drivers/message/fusion/lsi/mpi_cnfg.h | 60 +++------------------------ 1 file changed, 6 insertions(+), 54 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/6 scsi: message: fusion: struct _RAID_VOL0_SETTINGS: Replace 1-element array with flexible array
Replace the deprecated[1] use of a 1-element array in struct _RAID_VOL0_SETTINGS with a modern flexible array.
Additionally add __counted_by annotation since PhysDisk is only ever accessed via a loops bounded by NumPhysDisks:
lsi/mpi_cnfg.h: RAID_VOL0_PHYS_DISK PhysDisk[] __counted_by(NumPhysDisks); /* 28h */mptbase.c: for (i = 0; i < buffer->NumPhysDisks; i++) {mptbase.c: buffer->PhysDisk[i].PhysDiskNum, &phys_disk) != 0)mptsas.c: for (i = 0; i < buffer->NumPhysDisks; i++) {mptsas.c: buffer->PhysDisk[i].PhysDiskNum, &phys_disk) != 0)mptsas.c: for (i = 0; i < buffer->NumPhysDisks; i++) {mptsas.c: buffer->PhysDisk[i].PhysDiskNum, &phys_disk) != 0)
No binary differences are present after this conversion.
---
Cc: Sathya Prakash <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: Suganath Prabu Subramani <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/message/fusion/lsi/mpi_cnfg.h +1 -9
@@ -2295,14 +2295,6 @@ typedef struct _RAID_VOL0_SETTINGS#define MPI_RAID_HOT_SPARE_POOL_6 (0x40)#define MPI_RAID_HOT_SPARE_POOL_7 (0x80) -/* -* Host code (drivers, BIOS, utilities, etc.) should leave this define set to -* one and check Header.PageLength at runtime. -*/ -#ifndef MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX -#define MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX (1) -#endif - typedef struct _CONFIG_PAGE_RAID_VOL_0 { CONFIG_PAGE_HEADER Header; /* 00h */
@@ -2321,7 +2313,7 @@ typedef struct _CONFIG_PAGE_RAID_VOL_0U8 DataScrubRate;/* 25h */ U8 ResyncRate;/* 26h */ U8 InactiveStatus;/* 27h */ -RAID_VOL0_PHYS_DISK PhysDisk[MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX ];/* 28h */ + RAID_VOL0_PHYS_DISK PhysDisk[] __counted_by(NumPhysDisks); /* 28h */ } CONFIG_PAGE_RAID_VOL_0, MPI_POINTER PTR_CONFIG_PAGE_RAID_VOL_0, RaidVolumePage0_t, MPI_POINTER pRaidVolumePage0_t;
Signature · 1 line
2.34.1
Re: [PATCH 1/6] scsi: message: fusion: struct _RAID_VOL0_SETTINGS: Replace 1-element array with flexible array
Quoted 14 lines · Kees Cook
Replace the deprecated[1] use of a 1-element array in struct
_RAID_VOL0_SETTINGSwith a modern flexible array.Additionally add
__counted_byannotation since PhysDisk is only ever accessed via a loops bounded by NumPhysDisks:
lsi/mpi_cnfg.h:RAID_VOL0_PHYS_DISKPhysDisk[]__counted_by(NumPhysDisks); /* 28h */mptbase.c: for (i = 0; i <buffer->NumPhysDisks; i++) {mptbase.c: buffer->PhysDisk[i].PhysDiskNum,&phys_disk) != 0)mptsas.c: for (i = 0; i <buffer->NumPhysDisks; i++) {mptsas.c: buffer->PhysDisk[i].PhysDiskNum,&phys_disk) != 0)mptsas.c: for (i = 0; i <buffer->NumPhysDisks; i++) {mptsas.c: buffer->PhysDisk[i].PhysDiskNum,&phys_disk) != 0)
Quoted 4 lines
No binary differences are present after this conversion.
Signed-off-by Kees Cook <[email protected]>
Thanks!
Signature · 1 line
Gustavo
Quoted 40 lines
---
Cc: Sathya Prakash <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: Suganath Prabu Subramani <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)drivers/message/fusion/lsi/mpi_cnfg.h +1
-9@@ -2295,14 +2295,6 @@ typedef struct _RAID_VOL0_SETTINGS#define MPI_RAID_HOT_SPARE_POOL_6 (0x40)#define MPI_RAID_HOT_SPARE_POOL_7 (0x80) -/* -* Host code (drivers, BIOS, utilities, etc.) should leave this define set to -* one and check Header.PageLength at runtime. -*/ -#ifndef MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX -#define MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX (1) -#endif - typedef struct _CONFIG_PAGE_RAID_VOL_0 { CONFIG_PAGE_HEADER Header; /* 00h */@@ -2321,7 +2313,7 @@ typedef struct _CONFIG_PAGE_RAID_VOL_0U8 DataScrubRate;/* 25h */ U8 ResyncRate;/* 26h */ U8 InactiveStatus;/* 27h */ -RAID_VOL0_PHYS_DISK PhysDisk[MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX ];/* 28h */ + RAID_VOL0_PHYS_DISK PhysDisk[] __counted_by(NumPhysDisks); /* 28h */ } CONFIG_PAGE_RAID_VOL_0, MPI_POINTER PTR_CONFIG_PAGE_RAID_VOL_0, RaidVolumePage0_t, MPI_POINTER pRaidVolumePage0_t;
PATCH 2/6 scsi: message: fusion: struct _CONFIG_PAGE_SAS_IO_UNIT_0: Replace 1-element array with flexible array
In reply to Kees CookReplace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_SAS_IO_UNIT_0 with a modern flexible array.
Additionally add __counted_by annotation since PhyData is only ever accessed via a loops bounded by NumPhys:
lsi/mpi_cnfg.h: MPI_SAS_IO_UNIT0_PHY_DATA PhyData[] __counted_by(NumPhys); /* 10h */
mptsas.c: port_info->num_phys = buffer->NumPhys;
mptsas.c: for (i = 0; i < port_info->num_phys; i++) {
mptsas.c: mptsas_print_phy_data(ioc, &buffer->PhyData[i]);
mptsas.c: port_info->phy_info[i].phy_id = i;
mptsas.c: port_info->phy_info[i].port_id =
mptsas.c: buffer->PhyData[i].Port;
mptsas.c: port_info->phy_info[i].negotiated_link_rate =
mptsas.c: buffer->PhyData[i].NegotiatedLinkRate;No binary differences are present after this conversion.
---
Cc: Sathya Prakash <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: Suganath Prabu Subramani <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/message/fusion/lsi/mpi_cnfg.h +1 -9
@@ -2547,14 +2547,6 @@ typedef struct _MPI_SAS_IO_UNIT0_PHY_DATA } MPI_SAS_IO_UNIT0_PHY_DATA, MPI_POINTER PTR_MPI_SAS_IO_UNIT0_PHY_DATA, SasIOUnit0PhyData, MPI_POINTER pSasIOUnit0PhyData; -/* -* Host code (drivers, BIOS, utilities, etc.) should leave this define set to -* one and check Header.PageLength at runtime. -*/ -#ifndef MPI_SAS_IOUNIT0_PHY_MAX -#define MPI_SAS_IOUNIT0_PHY_MAX (1) -#endif - typedef struct _CONFIG_PAGE_SAS_IO_UNIT_0 { CONFIG_EXTENDED_PAGE_HEADER Header; /* 00h */
@@ -2563,7 +2555,7 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_0U8 NumPhys;/* 0Ch */ U8 Reserved2;/* 0Dh */ U16 Reserved3;/* 0Eh */ -MPI_SAS_IO_UNIT0_PHY_DATA PhyData[MPI_SAS_IOUNIT0_PHY_MAX ];/* 10h */ + MPI_SAS_IO_UNIT0_PHY_DATA PhyData[] __counted_by(NumPhys); /* 10h */ } CONFIG_PAGE_SAS_IO_UNIT_0, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_0, SasIOUnitPage0_t, MPI_POINTER pSasIOUnitPage0_t;
Signature · 1 line
2.34.1
Re: [PATCH 2/6] scsi: message: fusion: struct _CONFIG_PAGE_SAS_IO_UNIT_0: Replace 1-element array with flexible array
Quoted 16 lines · Kees Cook
Replace the deprecated[1] use of a 1-element array in struct
_CONFIG_PAGE_SAS_IO_UNIT_0with a modern flexible array.Additionally add
__counted_byannotation since PhyData is only ever accessed via a loops bounded by NumPhys:lsi/mpi_cnfg.h: MPI_SAS_IO_UNIT0_PHY_DATA PhyData[] __counted_by(NumPhys); /* 10h */ mptsas.c: port_info->num_phys = buffer->NumPhys; mptsas.c: for (i = 0; i < port_info->num_phys; i++) { mptsas.c: mptsas_print_phy_data(ioc, &buffer->PhyData[i]); mptsas.c: port_info->phy_info[i].phy_id = i; mptsas.c: port_info->phy_info[i].port_id = mptsas.c: buffer->PhyData[i].Port; mptsas.c: port_info->phy_info[i].negotiated_link_rate = mptsas.c: buffer->PhyData[i].NegotiatedLinkRate;
Quoted 4 lines
No binary differences are present after this conversion.
Signed-off-by Kees Cook <[email protected]>
Thanks!
Signature · 1 line
Gustavo
Quoted 40 lines
---
Cc: Sathya Prakash <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: Suganath Prabu Subramani <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)drivers/message/fusion/lsi/mpi_cnfg.h +1
-9@@ -2547,14 +2547,6 @@ typedef struct _MPI_SAS_IO_UNIT0_PHY_DATA } MPI_SAS_IO_UNIT0_PHY_DATA, MPI_POINTER PTR_MPI_SAS_IO_UNIT0_PHY_DATA, SasIOUnit0PhyData, MPI_POINTER pSasIOUnit0PhyData; -/* -* Host code (drivers, BIOS, utilities, etc.) should leave this define set to -* one and check Header.PageLength at runtime. -*/ -#ifndef MPI_SAS_IOUNIT0_PHY_MAX -#define MPI_SAS_IOUNIT0_PHY_MAX (1) -#endif - typedef struct _CONFIG_PAGE_SAS_IO_UNIT_0 { CONFIG_EXTENDED_PAGE_HEADER Header; /* 00h */@@ -2563,7 +2555,7 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_0U8 NumPhys;/* 0Ch */ U8 Reserved2;/* 0Dh */ U16 Reserved3;/* 0Eh */ -MPI_SAS_IO_UNIT0_PHY_DATA PhyData[MPI_SAS_IOUNIT0_PHY_MAX ];/* 10h */ + MPI_SAS_IO_UNIT0_PHY_DATA PhyData[] __counted_by(NumPhys); /* 10h */ } CONFIG_PAGE_SAS_IO_UNIT_0, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_0, SasIOUnitPage0_t, MPI_POINTER pSasIOUnitPage0_t;
PATCH 3/6 scsi: message: fusion: struct _CONFIG_PAGE_RAID_PHYS_DISK_1: Replace 1-element array with flexible array
In reply to Kees CookReplace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_RAID_PHYS_DISK_1 with a modern flexible array.
Additionally add __counted_by annotation since Path is only ever accessed via a loops bounded by NumPhysDiskPaths:
lsi/mpi_cnfg.h: RAID_PHYS_DISK1_PATH Path[] __counted_by(NumPhysDiskPaths);/* 0Ch */
mptbase.c: phys_disk->NumPhysDiskPaths = buffer->NumPhysDiskPaths;
mptbase.c: for (i = 0; i < phys_disk->NumPhysDiskPaths; i++) {
mptbase.c: phys_disk->Path[i].PhysDiskID = buffer->Path[i].PhysDiskID;
mptbase.c: phys_disk->Path[i].PhysDiskBus = buffer->Path[i].PhysDiskBus;No binary differences are present after this conversion.
---
Cc: Sathya Prakash <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: Suganath Prabu Subramani <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/message/fusion/lsi/mpi_cnfg.h +1 -9
@@ -2447,14 +2447,6 @@ typedef struct _RAID_PHYS_DISK1_PATH#define MPI_RAID_PHYSDISK1_FLAG_INVALID (0x0001) -/* -* Host code (drivers, BIOS, utilities, etc.) should leave this define set to -* one and check Header.PageLength or NumPhysDiskPaths at runtime. -*/ -#ifndef MPI_RAID_PHYS_DISK1_PATH_MAX -#define MPI_RAID_PHYS_DISK1_PATH_MAX (1) -#endif - typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_1 { CONFIG_PAGE_HEADER Header; /* 00h */
@@ -2462,7 +2454,7 @@ typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_1U8 PhysDiskNum;/* 05h */ U16 Reserved2;/* 06h */ U32 Reserved1;/* 08h */ -RAID_PHYS_DISK1_PATH Path[MPI_RAID_PHYS_DISK1_PATH_MAX ];/* 0Ch */ + RAID_PHYS_DISK1_PATH Path[] __counted_by(NumPhysDiskPaths);/* 0Ch */ } CONFIG_PAGE_RAID_PHYS_DISK_1, MPI_POINTER PTR_CONFIG_PAGE_RAID_PHYS_DISK_1, RaidPhysDiskPage1_t, MPI_POINTER pRaidPhysDiskPage1_t;
Signature · 1 line
2.34.1
Re: [PATCH 3/6] scsi: message: fusion: struct _CONFIG_PAGE_RAID_PHYS_DISK_1: Replace 1-element array with flexible array
Quoted 12 lines · Kees Cook
Replace the deprecated[1] use of a 1-element array in struct
_CONFIG_PAGE_RAID_PHYS_DISK_1with a modern flexible array.Additionally add
__counted_byannotation since Path is only ever accessed via a loops bounded by NumPhysDiskPaths:lsi/mpi_cnfg.h: RAID_PHYS_DISK1_PATH Path[] __counted_by(NumPhysDiskPaths);/* 0Ch */ mptbase.c: phys_disk->NumPhysDiskPaths = buffer->NumPhysDiskPaths; mptbase.c: for (i = 0; i < phys_disk->NumPhysDiskPaths; i++) { mptbase.c: phys_disk->Path[i].PhysDiskID = buffer->Path[i].PhysDiskID; mptbase.c: phys_disk->Path[i].PhysDiskBus = buffer->Path[i].PhysDiskBus;
Quoted 4 lines
No binary differences are present after this conversion.
Signed-off-by Kees Cook <[email protected]>
Thanks
Signature · 1 line
Gustavo
Quoted 40 lines
---
Cc: Sathya Prakash <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: Suganath Prabu Subramani <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)drivers/message/fusion/lsi/mpi_cnfg.h +1
-9@@ -2447,14 +2447,6 @@ typedef struct _RAID_PHYS_DISK1_PATH#define MPI_RAID_PHYSDISK1_FLAG_INVALID (0x0001) -/* -* Host code (drivers, BIOS, utilities, etc.) should leave this define set to -* one and check Header.PageLength or NumPhysDiskPaths at runtime. -*/ -#ifndef MPI_RAID_PHYS_DISK1_PATH_MAX -#define MPI_RAID_PHYS_DISK1_PATH_MAX (1) -#endif - typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_1 { CONFIG_PAGE_HEADER Header; /* 00h */@@ -2462,7 +2454,7 @@ typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_1U8 PhysDiskNum;/* 05h */ U16 Reserved2;/* 06h */ U32 Reserved1;/* 08h */ -RAID_PHYS_DISK1_PATH Path[MPI_RAID_PHYS_DISK1_PATH_MAX ];/* 0Ch */ + RAID_PHYS_DISK1_PATH Path[] __counted_by(NumPhysDiskPaths);/* 0Ch */ } CONFIG_PAGE_RAID_PHYS_DISK_1, MPI_POINTER PTR_CONFIG_PAGE_RAID_PHYS_DISK_1, RaidPhysDiskPage1_t, MPI_POINTER pRaidPhysDiskPage1_t;
PATCH 4/6 scsi: message: fusion: struct _CONFIG_PAGE_IOC_2: Replace 1-element array with flexible array
In reply to Kees CookReplace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_IOC_2 with a modern flexible array.
Additionally add __counted_by annotation since RaidVolume is only ever accessed from loops controlled by NumActiveVolumes:
lsi/mpi_cnfg.h: CONFIG_PAGE_IOC_2_RAID_VOL RaidVolume[] __counted_by(NumActiveVolumes); /* 0Ch */
mptbase.c: for (i = 0; i < pIoc2->NumActiveVolumes ; i++)
mptbase.c: pIoc2->RaidVolume[i].VolumeBus,
mptbase.c: pIoc2->RaidVolume[i].VolumeID);
mptsas.c: for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
mptsas.c: RaidVolume[i].VolumeID) {
mptsas.c: RaidVolume[i].VolumeBus;
mptsas.c: for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
mptsas.c: ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0);
mptsas.c: ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID);
mptsas.c: ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0);
mptsas.c: for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
mptsas.c: if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID ==
mptsas.c: for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++)
mptsas.c: if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id)
mptspi.c: for (i=0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
mptspi.c: if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id) {No binary differences are present after this conversion.
---
Cc: Sathya Prakash <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: Suganath Prabu Subramani <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/message/fusion/lsi/mpi_cnfg.h +1 -9
@@ -1018,14 +1018,6 @@ typedef struct _CONFIG_PAGE_IOC_2_RAID_VOL#define MPI_IOCPAGE2_FLAG_VOLUME_INACTIVE (0x08) -/* -* Host code (drivers, BIOS, utilities, etc.) should leave this define set to -* one and check Header.PageLength at runtime. -*/ -#ifndef MPI_IOC_PAGE_2_RAID_VOLUME_MAX -#define MPI_IOC_PAGE_2_RAID_VOLUME_MAX (1) -#endif - typedef struct _CONFIG_PAGE_IOC_2 { CONFIG_PAGE_HEADER Header; /* 00h */
@@ -1034,7 +1026,7 @@ typedef struct _CONFIG_PAGE_IOC_2U8 MaxVolumes;/* 09h */ U8 NumActivePhysDisks;/* 0Ah */ U8 MaxPhysDisks;/* 0Bh */ -CONFIG_PAGE_IOC_2_RAID_VOL RaidVolume[MPI_IOC_PAGE_2_RAID_VOLUME_MAX ];/* 0Ch */ + CONFIG_PAGE_IOC_2_RAID_VOL RaidVolume[] __counted_by(NumActiveVolumes); /* 0Ch */ } CONFIG_PAGE_IOC_2, MPI_POINTER PTR_CONFIG_PAGE_IOC_2, IOCPage2_t, MPI_POINTER pIOCPage2_t;
Signature · 1 line
2.34.1
Re: [PATCH 4/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_2: Replace 1-element array with flexible array
Quoted 24 lines · Kees Cook
Replace the deprecated[1] use of a 1-element array in struct
_CONFIG_PAGE_IOC_2with a modern flexible array.Additionally add
__counted_byannotation since RaidVolume is only ever accessed from loops controlled by NumActiveVolumes:lsi/mpi_cnfg.h: CONFIG_PAGE_IOC_2_RAID_VOL RaidVolume[] __counted_by(NumActiveVolumes); /* 0Ch */ mptbase.c: for (i = 0; i < pIoc2->NumActiveVolumes ; i++) mptbase.c: pIoc2->RaidVolume[i].VolumeBus, mptbase.c: pIoc2->RaidVolume[i].VolumeID); mptsas.c: for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { mptsas.c: RaidVolume[i].VolumeID) { mptsas.c: RaidVolume[i].VolumeBus; mptsas.c: for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { mptsas.c: ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0); mptsas.c: ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID); mptsas.c: ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0); mptsas.c: for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { mptsas.c: if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == mptsas.c: for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) mptsas.c: if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id) mptspi.c: for (i=0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { mptspi.c: if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id) {
Quoted 4 lines
No binary differences are present after this conversion.
Signed-off-by Kees Cook <[email protected]>
Thanks
Signature · 1 line
Gustavo
Quoted 40 lines
---
Cc: Sathya Prakash <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: Suganath Prabu Subramani <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)drivers/message/fusion/lsi/mpi_cnfg.h +1
-9@@ -1018,14 +1018,6 @@ typedef struct _CONFIG_PAGE_IOC_2_RAID_VOL#define MPI_IOCPAGE2_FLAG_VOLUME_INACTIVE (0x08) -/* -* Host code (drivers, BIOS, utilities, etc.) should leave this define set to -* one and check Header.PageLength at runtime. -*/ -#ifndef MPI_IOC_PAGE_2_RAID_VOLUME_MAX -#define MPI_IOC_PAGE_2_RAID_VOLUME_MAX (1) -#endif - typedef struct _CONFIG_PAGE_IOC_2 { CONFIG_PAGE_HEADER Header; /* 00h */@@ -1034,7 +1026,7 @@ typedef struct _CONFIG_PAGE_IOC_2U8 MaxVolumes;/* 09h */ U8 NumActivePhysDisks;/* 0Ah */ U8 MaxPhysDisks;/* 0Bh */ -CONFIG_PAGE_IOC_2_RAID_VOL RaidVolume[MPI_IOC_PAGE_2_RAID_VOLUME_MAX ];/* 0Ch */ + CONFIG_PAGE_IOC_2_RAID_VOL RaidVolume[] __counted_by(NumActiveVolumes); /* 0Ch */ } CONFIG_PAGE_IOC_2, MPI_POINTER PTR_CONFIG_PAGE_IOC_2, IOCPage2_t, MPI_POINTER pIOCPage2_t;
PATCH 5/6 scsi: message: fusion: struct _CONFIG_PAGE_IOC_3: Replace 1-element array with flexible array
In reply to Kees CookReplace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_IOC_3 with a modern flexible array.
Additionally add __counted_by annotation since PhysDisk is only ever accessed via a loops bounded by NumPhysDisks:
lsi/mpi_cnfg.h: IOC_3_PHYS_DISK PhysDisk[] __counted_by(NumPhysDisks); /* 08h */mptscsih.c: for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) {mptscsih.c: if ((id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID) &&mptscsih.c: (channel == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskBus)) {mptscsih.c: for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) {mptscsih.c: ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum);mptscsih.c: ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum,mptscsih.c: for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) {mptscsih.c: if ((id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID) &&mptscsih.c: (channel == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskBus)) {mptscsih.c: rc = ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum;mptscsih.c: for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) {mptscsih.c: ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum);mptscsih.c: ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum,
No binary differences are present after this conversion.
---
Cc: Sathya Prakash <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: Suganath Prabu Subramani <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/message/fusion/lsi/mpi_cnfg.h +1 -9
@@ -1056,21 +1056,13 @@ typedef struct _IOC_3_PHYS_DISK } IOC_3_PHYS_DISK, MPI_POINTER PTR_IOC_3_PHYS_DISK, Ioc3PhysDisk_t, MPI_POINTER pIoc3PhysDisk_t; -/* -* Host code (drivers, BIOS, utilities, etc.) should leave this define set to -* one and check Header.PageLength at runtime. -*/ -#ifndef MPI_IOC_PAGE_3_PHYSDISK_MAX -#define MPI_IOC_PAGE_3_PHYSDISK_MAX (1) -#endif -typedef struct _CONFIG_PAGE_IOC_3 {CONFIG_PAGE_HEADER Header;/* 00h */ U8 NumPhysDisks;/* 04h */ U8 Reserved1;/* 05h */ U16 Reserved2;/* 06h */ -IOC_3_PHYS_DISK PhysDisk[MPI_IOC_PAGE_3_PHYSDISK_MAX ];/* 08h */ + IOC_3_PHYS_DISK PhysDisk[] __counted_by(NumPhysDisks); /* 08h */ } CONFIG_PAGE_IOC_3, MPI_POINTER PTR_CONFIG_PAGE_IOC_3, IOCPage3_t, MPI_POINTER pIOCPage3_t;
Signature · 1 line
2.34.1
Re: [PATCH 5/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_3: Replace 1-element array with flexible array
Quoted 21 lines · Kees Cook
Replace the deprecated[1] use of a 1-element array in struct
_CONFIG_PAGE_IOC_3with a modern flexible array.Additionally add
__counted_byannotation since PhysDisk is only ever accessed via a loops bounded by NumPhysDisks:
lsi/mpi_cnfg.h:IOC_3_PHYS_DISKPhysDisk[]__counted_by(NumPhysDisks); /* 08h */mptscsih.c: for (i = 0; i <ioc->raid_data.pIocPg3->NumPhysDisks; i++) {mptscsih.c: if ((id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID) &&mptscsih.c: (channel == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskBus)) {mptscsih.c: for (i = 0; i <ioc->raid_data.pIocPg3->NumPhysDisks; i++) {mptscsih.c: ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum);mptscsih.c: ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum,mptscsih.c: for (i = 0; i <ioc->raid_data.pIocPg3->NumPhysDisks; i++) {mptscsih.c: if ((id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID) &&mptscsih.c: (channel == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskBus)) {mptscsih.c: rc = ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum;mptscsih.c: for (i = 0; i <ioc->raid_data.pIocPg3->NumPhysDisks; i++) {mptscsih.c: ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum);mptscsih.c: ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum,
Quoted 4 lines
No binary differences are present after this conversion.
Signed-off-by Kees Cook <[email protected]>
Thanks
Signature · 1 line
Gustavo
Quoted 39 lines
---
Cc: Sathya Prakash <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: Suganath Prabu Subramani <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)drivers/message/fusion/lsi/mpi_cnfg.h +1
-9@@ -1056,21 +1056,13 @@ typedef struct _IOC_3_PHYS_DISK } IOC_3_PHYS_DISK, MPI_POINTER PTR_IOC_3_PHYS_DISK, Ioc3PhysDisk_t, MPI_POINTER pIoc3PhysDisk_t; -/* -* Host code (drivers, BIOS, utilities, etc.) should leave this define set to -* one and check Header.PageLength at runtime. -*/ -#ifndef MPI_IOC_PAGE_3_PHYSDISK_MAX -#define MPI_IOC_PAGE_3_PHYSDISK_MAX (1) -#endif -typedef struct _CONFIG_PAGE_IOC_3 {CONFIG_PAGE_HEADER Header;/* 00h */ U8 NumPhysDisks;/* 04h */ U8 Reserved1;/* 05h */ U16 Reserved2;/* 06h */ -IOC_3_PHYS_DISK PhysDisk[MPI_IOC_PAGE_3_PHYSDISK_MAX ];/* 08h */ + IOC_3_PHYS_DISK PhysDisk[] __counted_by(NumPhysDisks); /* 08h */ } CONFIG_PAGE_IOC_3, MPI_POINTER PTR_CONFIG_PAGE_IOC_3, IOCPage3_t, MPI_POINTER pIOCPage3_t;
PATCH 6/6 scsi: message: fusion: struct _CONFIG_PAGE_IOC_4: Replace 1-element array with flexible array
In reply to Kees CookReplace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_IOC_4 with a modern flexible array.
Additionally add __counted_by annotation since SEP is only ever accessed after updating ACtiveSEP:
lsi/mpi_cnfg.h: IOC_4_SEP SEP[] __counted_by(ActiveSEP); /* 08h */ mptsas.c: ii = IOCPage4Ptr->ActiveSEP++; mptsas.c: IOCPage4Ptr->SEP[ii].SEPTargetID = id; mptsas.c: IOCPage4Ptr->SEP[ii].SEPBus = channel;
No binary differences are present after this conversion.
---
Cc: Sathya Prakash <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: Suganath Prabu Subramani <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/message/fusion/lsi/mpi_cnfg.h +1 -9
@@ -1077,21 +1077,13 @@ typedef struct _IOC_4_SEP } IOC_4_SEP, MPI_POINTER PTR_IOC_4_SEP, Ioc4Sep_t, MPI_POINTER pIoc4Sep_t; -/* -* Host code (drivers, BIOS, utilities, etc.) should leave this define set to -* one and check Header.PageLength at runtime. -*/ -#ifndef MPI_IOC_PAGE_4_SEP_MAX -#define MPI_IOC_PAGE_4_SEP_MAX (1) -#endif -typedef struct _CONFIG_PAGE_IOC_4 {CONFIG_PAGE_HEADER Header;/* 00h */ U8 ActiveSEP;/* 04h */ U8 MaxSEP;/* 05h */ U16 Reserved1;/* 06h */ -IOC_4_SEP SEP[MPI_IOC_PAGE_4_SEP_MAX ];/* 08h */ + IOC_4_SEP SEP[] __counted_by(ActiveSEP); /* 08h */ } CONFIG_PAGE_IOC_4, MPI_POINTER PTR_CONFIG_PAGE_IOC_4, IOCPage4_t, MPI_POINTER pIOCPage4_t;
Signature · 1 line
2.34.1
Re: [PATCH 6/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_4: Replace 1-element array with flexible array
Quoted 11 lines · Kees Cook
Replace the deprecated[1] use of a 1-element array in struct
_CONFIG_PAGE_IOC_4with a modern flexible array.Additionally add
__counted_byannotation since SEP is only ever accessed after updating ACtiveSEP:lsi/mpi_cnfg.h: IOC_4_SEP SEP[] __counted_by(ActiveSEP); /* 08h */ mptsas.c: ii = IOCPage4Ptr->ActiveSEP++; mptsas.c: IOCPage4Ptr->SEP[ii].SEPTargetID = id; mptsas.c: IOCPage4Ptr->SEP[ii].SEPBus = channel;
Quoted 4 lines
No binary differences are present after this conversion.
Signed-off-by Kees Cook <[email protected]>
Thanks!
Signature · 1 line
Gustavo
Quoted 39 lines
---
Cc: Sathya Prakash <[email protected]>
Cc: Sreekanth Reddy <[email protected]>
Cc: Suganath Prabu Subramani <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)drivers/message/fusion/lsi/mpi_cnfg.h +1
-9@@ -1077,21 +1077,13 @@ typedef struct _IOC_4_SEP } IOC_4_SEP, MPI_POINTER PTR_IOC_4_SEP, Ioc4Sep_t, MPI_POINTER pIoc4Sep_t; -/* -* Host code (drivers, BIOS, utilities, etc.) should leave this define set to -* one and check Header.PageLength at runtime. -*/ -#ifndef MPI_IOC_PAGE_4_SEP_MAX -#define MPI_IOC_PAGE_4_SEP_MAX (1) -#endif -typedef struct _CONFIG_PAGE_IOC_4 {CONFIG_PAGE_HEADER Header;/* 00h */ U8 ActiveSEP;/* 04h */ U8 MaxSEP;/* 05h */ U16 Reserved1;/* 06h */ -IOC_4_SEP SEP[MPI_IOC_PAGE_4_SEP_MAX ];/* 08h */ + IOC_4_SEP SEP[] __counted_by(ActiveSEP); /* 08h */ } CONFIG_PAGE_IOC_4, MPI_POINTER PTR_CONFIG_PAGE_IOC_4, IOCPage4_t, MPI_POINTER pIOCPage4_t;
Martin K. Petersen
AppliedKees,
Quoted 3 lines
Replace all remaining uses of deprecated 1-element "fake" flexible arrays with modern C99 flexible arrays. Add
__counted_byannotations at the same time.
Applied to 6.12/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 9 lines · Kees Cook
Replace all remaining uses of deprecated 1-element "fake" flexible arrays with modern C99 flexible arrays. Add
__counted_byannotations at the same time.Thanks!
-Kees
[...]
Applied to 6.12/scsi-queue, thanks!
[1/6] scsi: message: fusion: struct _RAID_VOL0_SETTINGS: Replace 1-element array with flexible array
https://git.kernel.org/mkp/scsi/c/8e76c9c9dd11 [2/6] scsi: message: fusion: struct _CONFIG_PAGE_SAS_IO_UNIT_0: Replace 1-element array with flexible array https://git.kernel.org/mkp/scsi/c/14c1f88c7f62 [3/6] scsi: message: fusion: struct _CONFIG_PAGE_RAID_PHYS_DISK_1: Replace 1-element array with flexible array https://git.kernel.org/mkp/scsi/c/dc8932fbf6a9 [4/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_2: Replace 1-element array with flexible array https://git.kernel.org/mkp/scsi/c/de80fe29ab53 [5/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_3: Replace 1-element array with flexible array https://git.kernel.org/mkp/scsi/c/70631322dbab [6/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_4: Replace 1-element array with flexible array https://git.kernel.org/mkp/scsi/c/f296cc1d7f5a
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering