Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: message: fusion: struct _CONFIG_PAGE_IOC_4: Replace 1-element array with flexible array

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>
Link: https://lore.kernel.org/r/20240711172821.123936-6-kees@kernel.org
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Kees Cook and committed by
Martin K. Petersen
f296cc1d 70631322

+1 -9
+1 -9
drivers/message/fusion/lsi/mpi_cnfg.h
··· 1077 1077 } IOC_4_SEP, MPI_POINTER PTR_IOC_4_SEP, 1078 1078 Ioc4Sep_t, MPI_POINTER pIoc4Sep_t; 1079 1079 1080 - /* 1081 - * Host code (drivers, BIOS, utilities, etc.) should leave this define set to 1082 - * one and check Header.PageLength at runtime. 1083 - */ 1084 - #ifndef MPI_IOC_PAGE_4_SEP_MAX 1085 - #define MPI_IOC_PAGE_4_SEP_MAX (1) 1086 - #endif 1087 - 1088 1080 typedef struct _CONFIG_PAGE_IOC_4 1089 1081 { 1090 1082 CONFIG_PAGE_HEADER Header; /* 00h */ 1091 1083 U8 ActiveSEP; /* 04h */ 1092 1084 U8 MaxSEP; /* 05h */ 1093 1085 U16 Reserved1; /* 06h */ 1094 - IOC_4_SEP SEP[MPI_IOC_PAGE_4_SEP_MAX]; /* 08h */ 1086 + IOC_4_SEP SEP[] __counted_by(ActiveSEP); /* 08h */ 1095 1087 } CONFIG_PAGE_IOC_4, MPI_POINTER PTR_CONFIG_PAGE_IOC_4, 1096 1088 IOCPage4_t, MPI_POINTER pIOCPage4_t; 1097 1089