* [PATCH 1/6] scsi: message: fusion: struct _RAID_VOL0_SETTINGS: Replace 1-element array with flexible array
2024-07-11 17:28 [PATCH 0/6] scsi: message: fusion: Replace 1-element arrays with flexible arrays Kees Cook
@ 2024-07-11 17:28 ` Kees Cook
2024-07-11 18:12 ` Gustavo A. R. Silva
2024-07-11 17:28 ` [PATCH 2/6] scsi: message: fusion: struct _CONFIG_PAGE_SAS_IO_UNIT_0: " Kees Cook
` (6 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Kees Cook @ 2024-07-11 17:28 UTC (permalink / raw)
To: Sathya Prakash
Cc: Kees Cook, Sreekanth Reddy, Suganath Prabu Subramani,
Gustavo A. R. Silva, MPT-FusionLinux.pdl, linux-scsi,
linux-hardening, linux-kernel
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.
Link: https://github.com/KSPP/linux/issues/79 [1]
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: MPT-FusionLinux.pdl@broadcom.com
Cc: linux-scsi@vger.kernel.org
Cc: linux-hardening@vger.kernel.org
---
drivers/message/fusion/lsi/mpi_cnfg.h | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h
index 3770cb1cff7d..f59a741ef21c 100644
--- a/drivers/message/fusion/lsi/mpi_cnfg.h
+++ b/drivers/message/fusion/lsi/mpi_cnfg.h
@@ -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_0
U8 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;
--
2.34.1
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 1/6] scsi: message: fusion: struct _RAID_VOL0_SETTINGS: Replace 1-element array with flexible array
2024-07-11 17:28 ` [PATCH 1/6] scsi: message: fusion: struct _RAID_VOL0_SETTINGS: Replace 1-element array with flexible array Kees Cook
@ 2024-07-11 18:12 ` Gustavo A. R. Silva
0 siblings, 0 replies; 15+ messages in thread
From: Gustavo A. R. Silva @ 2024-07-11 18:12 UTC (permalink / raw)
To: Kees Cook, Sathya Prakash
Cc: Sreekanth Reddy, Suganath Prabu Subramani, Gustavo A. R. Silva,
MPT-FusionLinux.pdl, linux-scsi, linux-hardening, linux-kernel
On 11/07/24 11:28, Kees Cook wrote:
> 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.
>
> Link: https://github.com/KSPP/linux/issues/79 [1]
> Signed-off-by: Kees Cook <kees@kernel.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Thanks!
--
Gustavo
> ---
> Cc: Sathya Prakash <sathya.prakash@broadcom.com>
> Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
> Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: MPT-FusionLinux.pdl@broadcom.com
> Cc: linux-scsi@vger.kernel.org
> Cc: linux-hardening@vger.kernel.org
> ---
> drivers/message/fusion/lsi/mpi_cnfg.h | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h
> index 3770cb1cff7d..f59a741ef21c 100644
> --- a/drivers/message/fusion/lsi/mpi_cnfg.h
> +++ b/drivers/message/fusion/lsi/mpi_cnfg.h
> @@ -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_0
> U8 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;
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 2/6] scsi: message: fusion: struct _CONFIG_PAGE_SAS_IO_UNIT_0: Replace 1-element array with flexible array
2024-07-11 17:28 [PATCH 0/6] scsi: message: fusion: Replace 1-element arrays with flexible arrays Kees Cook
2024-07-11 17:28 ` [PATCH 1/6] scsi: message: fusion: struct _RAID_VOL0_SETTINGS: Replace 1-element array with flexible array Kees Cook
@ 2024-07-11 17:28 ` Kees Cook
2024-07-11 18:14 ` Gustavo A. R. Silva
2024-07-11 17:28 ` [PATCH 3/6] scsi: message: fusion: struct _CONFIG_PAGE_RAID_PHYS_DISK_1: " Kees Cook
` (5 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Kees Cook @ 2024-07-11 17:28 UTC (permalink / raw)
To: Sathya Prakash
Cc: Kees Cook, Sreekanth Reddy, Suganath Prabu Subramani,
Gustavo A. R. Silva, MPT-FusionLinux.pdl, linux-scsi,
linux-hardening, linux-kernel
Replace 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.
Link: https://github.com/KSPP/linux/issues/79 [1]
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: MPT-FusionLinux.pdl@broadcom.com
Cc: linux-scsi@vger.kernel.org
Cc: linux-hardening@vger.kernel.org
---
drivers/message/fusion/lsi/mpi_cnfg.h | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h
index f59a741ef21c..c7997e32e82e 100644
--- a/drivers/message/fusion/lsi/mpi_cnfg.h
+++ b/drivers/message/fusion/lsi/mpi_cnfg.h
@@ -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_0
U8 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;
--
2.34.1
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 2/6] scsi: message: fusion: struct _CONFIG_PAGE_SAS_IO_UNIT_0: Replace 1-element array with flexible array
2024-07-11 17:28 ` [PATCH 2/6] scsi: message: fusion: struct _CONFIG_PAGE_SAS_IO_UNIT_0: " Kees Cook
@ 2024-07-11 18:14 ` Gustavo A. R. Silva
0 siblings, 0 replies; 15+ messages in thread
From: Gustavo A. R. Silva @ 2024-07-11 18:14 UTC (permalink / raw)
To: Kees Cook, Sathya Prakash
Cc: Sreekanth Reddy, Suganath Prabu Subramani, Gustavo A. R. Silva,
MPT-FusionLinux.pdl, linux-scsi, linux-hardening, linux-kernel
On 11/07/24 11:28, Kees Cook wrote:
> Replace 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.
>
> Link: https://github.com/KSPP/linux/issues/79 [1]
> Signed-off-by: Kees Cook <kees@kernel.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Thanks!
--
Gustavo
> ---
> Cc: Sathya Prakash <sathya.prakash@broadcom.com>
> Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
> Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: MPT-FusionLinux.pdl@broadcom.com
> Cc: linux-scsi@vger.kernel.org
> Cc: linux-hardening@vger.kernel.org
> ---
> drivers/message/fusion/lsi/mpi_cnfg.h | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h
> index f59a741ef21c..c7997e32e82e 100644
> --- a/drivers/message/fusion/lsi/mpi_cnfg.h
> +++ b/drivers/message/fusion/lsi/mpi_cnfg.h
> @@ -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_0
> U8 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;
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 3/6] scsi: message: fusion: struct _CONFIG_PAGE_RAID_PHYS_DISK_1: Replace 1-element array with flexible array
2024-07-11 17:28 [PATCH 0/6] scsi: message: fusion: Replace 1-element arrays with flexible arrays Kees Cook
2024-07-11 17:28 ` [PATCH 1/6] scsi: message: fusion: struct _RAID_VOL0_SETTINGS: Replace 1-element array with flexible array Kees Cook
2024-07-11 17:28 ` [PATCH 2/6] scsi: message: fusion: struct _CONFIG_PAGE_SAS_IO_UNIT_0: " Kees Cook
@ 2024-07-11 17:28 ` Kees Cook
2024-07-11 18:16 ` Gustavo A. R. Silva
2024-07-11 17:28 ` [PATCH 4/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_2: " Kees Cook
` (4 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Kees Cook @ 2024-07-11 17:28 UTC (permalink / raw)
To: Sathya Prakash
Cc: Kees Cook, Sreekanth Reddy, Suganath Prabu Subramani,
Gustavo A. R. Silva, MPT-FusionLinux.pdl, linux-scsi,
linux-hardening, linux-kernel
Replace 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.
Link: https://github.com/KSPP/linux/issues/79 [1]
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: MPT-FusionLinux.pdl@broadcom.com
Cc: linux-scsi@vger.kernel.org
Cc: linux-hardening@vger.kernel.org
---
drivers/message/fusion/lsi/mpi_cnfg.h | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h
index c7997e32e82e..e30132b57ae7 100644
--- a/drivers/message/fusion/lsi/mpi_cnfg.h
+++ b/drivers/message/fusion/lsi/mpi_cnfg.h
@@ -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_1
U8 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;
--
2.34.1
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 3/6] scsi: message: fusion: struct _CONFIG_PAGE_RAID_PHYS_DISK_1: Replace 1-element array with flexible array
2024-07-11 17:28 ` [PATCH 3/6] scsi: message: fusion: struct _CONFIG_PAGE_RAID_PHYS_DISK_1: " Kees Cook
@ 2024-07-11 18:16 ` Gustavo A. R. Silva
0 siblings, 0 replies; 15+ messages in thread
From: Gustavo A. R. Silva @ 2024-07-11 18:16 UTC (permalink / raw)
To: Kees Cook, Sathya Prakash
Cc: Sreekanth Reddy, Suganath Prabu Subramani, Gustavo A. R. Silva,
MPT-FusionLinux.pdl, linux-scsi, linux-hardening, linux-kernel
On 11/07/24 11:28, Kees Cook wrote:
> Replace 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.
>
> Link: https://github.com/KSPP/linux/issues/79 [1]
> Signed-off-by: Kees Cook <kees@kernel.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Thanks
--
Gustavo
> ---
> Cc: Sathya Prakash <sathya.prakash@broadcom.com>
> Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
> Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: MPT-FusionLinux.pdl@broadcom.com
> Cc: linux-scsi@vger.kernel.org
> Cc: linux-hardening@vger.kernel.org
> ---
> drivers/message/fusion/lsi/mpi_cnfg.h | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h
> index c7997e32e82e..e30132b57ae7 100644
> --- a/drivers/message/fusion/lsi/mpi_cnfg.h
> +++ b/drivers/message/fusion/lsi/mpi_cnfg.h
> @@ -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_1
> U8 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;
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 4/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_2: Replace 1-element array with flexible array
2024-07-11 17:28 [PATCH 0/6] scsi: message: fusion: Replace 1-element arrays with flexible arrays Kees Cook
` (2 preceding siblings ...)
2024-07-11 17:28 ` [PATCH 3/6] scsi: message: fusion: struct _CONFIG_PAGE_RAID_PHYS_DISK_1: " Kees Cook
@ 2024-07-11 17:28 ` Kees Cook
2024-07-11 18:17 ` Gustavo A. R. Silva
2024-07-11 17:28 ` [PATCH 5/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_3: " Kees Cook
` (3 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Kees Cook @ 2024-07-11 17:28 UTC (permalink / raw)
To: Sathya Prakash
Cc: Kees Cook, Sreekanth Reddy, Suganath Prabu Subramani,
Gustavo A. R. Silva, MPT-FusionLinux.pdl, linux-scsi,
linux-hardening, linux-kernel
Replace 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.
Link: https://github.com/KSPP/linux/issues/79 [1]
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: MPT-FusionLinux.pdl@broadcom.com
Cc: linux-scsi@vger.kernel.org
Cc: linux-hardening@vger.kernel.org
---
drivers/message/fusion/lsi/mpi_cnfg.h | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h
index e30132b57ae7..7713c74e515b 100644
--- a/drivers/message/fusion/lsi/mpi_cnfg.h
+++ b/drivers/message/fusion/lsi/mpi_cnfg.h
@@ -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_2
U8 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;
--
2.34.1
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 4/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_2: Replace 1-element array with flexible array
2024-07-11 17:28 ` [PATCH 4/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_2: " Kees Cook
@ 2024-07-11 18:17 ` Gustavo A. R. Silva
0 siblings, 0 replies; 15+ messages in thread
From: Gustavo A. R. Silva @ 2024-07-11 18:17 UTC (permalink / raw)
To: Kees Cook, Sathya Prakash
Cc: Sreekanth Reddy, Suganath Prabu Subramani, Gustavo A. R. Silva,
MPT-FusionLinux.pdl, linux-scsi, linux-hardening, linux-kernel
On 11/07/24 11:28, Kees Cook wrote:
> Replace 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.
>
> Link: https://github.com/KSPP/linux/issues/79 [1]
> Signed-off-by: Kees Cook <kees@kernel.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Thanks
--
Gustavo
> ---
> Cc: Sathya Prakash <sathya.prakash@broadcom.com>
> Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
> Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: MPT-FusionLinux.pdl@broadcom.com
> Cc: linux-scsi@vger.kernel.org
> Cc: linux-hardening@vger.kernel.org
> ---
> drivers/message/fusion/lsi/mpi_cnfg.h | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h
> index e30132b57ae7..7713c74e515b 100644
> --- a/drivers/message/fusion/lsi/mpi_cnfg.h
> +++ b/drivers/message/fusion/lsi/mpi_cnfg.h
> @@ -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_2
> U8 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;
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 5/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_3: Replace 1-element array with flexible array
2024-07-11 17:28 [PATCH 0/6] scsi: message: fusion: Replace 1-element arrays with flexible arrays Kees Cook
` (3 preceding siblings ...)
2024-07-11 17:28 ` [PATCH 4/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_2: " Kees Cook
@ 2024-07-11 17:28 ` Kees Cook
2024-07-11 18:18 ` Gustavo A. R. Silva
2024-07-11 17:28 ` [PATCH 6/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_4: " Kees Cook
` (2 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Kees Cook @ 2024-07-11 17:28 UTC (permalink / raw)
To: Sathya Prakash
Cc: Kees Cook, Sreekanth Reddy, Suganath Prabu Subramani,
Gustavo A. R. Silva, MPT-FusionLinux.pdl, linux-scsi,
linux-hardening, linux-kernel
Replace 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.
Link: https://github.com/KSPP/linux/issues/79 [1]
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: MPT-FusionLinux.pdl@broadcom.com
Cc: linux-scsi@vger.kernel.org
Cc: linux-hardening@vger.kernel.org
---
drivers/message/fusion/lsi/mpi_cnfg.h | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h
index 7713c74e515b..bac49c162165 100644
--- a/drivers/message/fusion/lsi/mpi_cnfg.h
+++ b/drivers/message/fusion/lsi/mpi_cnfg.h
@@ -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;
--
2.34.1
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 5/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_3: Replace 1-element array with flexible array
2024-07-11 17:28 ` [PATCH 5/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_3: " Kees Cook
@ 2024-07-11 18:18 ` Gustavo A. R. Silva
0 siblings, 0 replies; 15+ messages in thread
From: Gustavo A. R. Silva @ 2024-07-11 18:18 UTC (permalink / raw)
To: Kees Cook, Sathya Prakash
Cc: Sreekanth Reddy, Suganath Prabu Subramani, Gustavo A. R. Silva,
MPT-FusionLinux.pdl, linux-scsi, linux-hardening, linux-kernel
On 11/07/24 11:28, Kees Cook wrote:
> Replace 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.
>
> Link: https://github.com/KSPP/linux/issues/79 [1]
> Signed-off-by: Kees Cook <kees@kernel.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Thanks
--
Gustavo
> ---
> Cc: Sathya Prakash <sathya.prakash@broadcom.com>
> Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
> Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: MPT-FusionLinux.pdl@broadcom.com
> Cc: linux-scsi@vger.kernel.org
> Cc: linux-hardening@vger.kernel.org
> ---
> drivers/message/fusion/lsi/mpi_cnfg.h | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h
> index 7713c74e515b..bac49c162165 100644
> --- a/drivers/message/fusion/lsi/mpi_cnfg.h
> +++ b/drivers/message/fusion/lsi/mpi_cnfg.h
> @@ -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;
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 6/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_4: Replace 1-element array with flexible array
2024-07-11 17:28 [PATCH 0/6] scsi: message: fusion: Replace 1-element arrays with flexible arrays Kees Cook
` (4 preceding siblings ...)
2024-07-11 17:28 ` [PATCH 5/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_3: " Kees Cook
@ 2024-07-11 17:28 ` Kees Cook
2024-07-11 18:19 ` Gustavo A. R. Silva
2024-08-03 1:33 ` [PATCH 0/6] scsi: message: fusion: Replace 1-element arrays with flexible arrays Martin K. Petersen
2024-08-05 21:17 ` Martin K. Petersen
7 siblings, 1 reply; 15+ messages in thread
From: Kees Cook @ 2024-07-11 17:28 UTC (permalink / raw)
To: Sathya Prakash
Cc: Kees Cook, Sreekanth Reddy, Suganath Prabu Subramani,
Gustavo A. R. Silva, MPT-FusionLinux.pdl, linux-scsi,
linux-hardening, linux-kernel
Replace 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.
Link: https://github.com/KSPP/linux/issues/79 [1]
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: MPT-FusionLinux.pdl@broadcom.com
Cc: linux-scsi@vger.kernel.org
Cc: linux-hardening@vger.kernel.org
---
drivers/message/fusion/lsi/mpi_cnfg.h | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h
index bac49c162165..1167a16d8fb4 100644
--- a/drivers/message/fusion/lsi/mpi_cnfg.h
+++ b/drivers/message/fusion/lsi/mpi_cnfg.h
@@ -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;
--
2.34.1
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 6/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_4: Replace 1-element array with flexible array
2024-07-11 17:28 ` [PATCH 6/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_4: " Kees Cook
@ 2024-07-11 18:19 ` Gustavo A. R. Silva
0 siblings, 0 replies; 15+ messages in thread
From: Gustavo A. R. Silva @ 2024-07-11 18:19 UTC (permalink / raw)
To: Kees Cook, Sathya Prakash
Cc: Sreekanth Reddy, Suganath Prabu Subramani, Gustavo A. R. Silva,
MPT-FusionLinux.pdl, linux-scsi, linux-hardening, linux-kernel
On 11/07/24 11:28, Kees Cook wrote:
> Replace 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.
>
> Link: https://github.com/KSPP/linux/issues/79 [1]
> Signed-off-by: Kees Cook <kees@kernel.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Thanks!
--
Gustavo
> ---
> Cc: Sathya Prakash <sathya.prakash@broadcom.com>
> Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
> Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: MPT-FusionLinux.pdl@broadcom.com
> Cc: linux-scsi@vger.kernel.org
> Cc: linux-hardening@vger.kernel.org
> ---
> drivers/message/fusion/lsi/mpi_cnfg.h | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h
> index bac49c162165..1167a16d8fb4 100644
> --- a/drivers/message/fusion/lsi/mpi_cnfg.h
> +++ b/drivers/message/fusion/lsi/mpi_cnfg.h
> @@ -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;
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 0/6] scsi: message: fusion: Replace 1-element arrays with flexible arrays
2024-07-11 17:28 [PATCH 0/6] scsi: message: fusion: Replace 1-element arrays with flexible arrays Kees Cook
` (5 preceding siblings ...)
2024-07-11 17:28 ` [PATCH 6/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_4: " Kees Cook
@ 2024-08-03 1:33 ` Martin K. Petersen
2024-08-05 21:17 ` Martin K. Petersen
7 siblings, 0 replies; 15+ messages in thread
From: Martin K. Petersen @ 2024-08-03 1:33 UTC (permalink / raw)
To: Kees Cook
Cc: Sathya Prakash, Sreekanth Reddy, Suganath Prabu Subramani,
Gustavo A. R. Silva, linux-kernel, MPT-FusionLinux.pdl,
linux-scsi, linux-hardening
Kees,
> Replace all remaining uses of deprecated 1-element "fake" flexible
> arrays with modern C99 flexible arrays. Add __counted_by annotations
> at the same time.
Applied to 6.12/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 0/6] scsi: message: fusion: Replace 1-element arrays with flexible arrays
2024-07-11 17:28 [PATCH 0/6] scsi: message: fusion: Replace 1-element arrays with flexible arrays Kees Cook
` (6 preceding siblings ...)
2024-08-03 1:33 ` [PATCH 0/6] scsi: message: fusion: Replace 1-element arrays with flexible arrays Martin K. Petersen
@ 2024-08-05 21:17 ` Martin K. Petersen
7 siblings, 0 replies; 15+ messages in thread
From: Martin K. Petersen @ 2024-08-05 21:17 UTC (permalink / raw)
To: Sathya Prakash, Kees Cook
Cc: Martin K . Petersen, Sreekanth Reddy, Suganath Prabu Subramani,
Gustavo A. R. Silva, linux-kernel, MPT-FusionLinux.pdl,
linux-scsi, linux-hardening
On Thu, 11 Jul 2024 10:28:14 -0700, Kees Cook wrote:
> 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
>
> [...]
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
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 15+ messages in thread