Message ID | 20240711155637.3757036-1-kees@kernel.org (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | scsi: mpi3mr: Replace 1-element arrays with flexible arrays | expand |
On 11/07/24 09:56, Kees Cook wrote: > Replace the deprecated[1] use of a 1-element array in > struct mpi3_event_data_sas_topology_change_list with a modern > flexible array. > > Additionally add __counted_by annotation since phy_entry is only ever > accessed in loops controlled by num_entries. For example: > > for (i = 0; i < event_data->num_entries; i++) { > ... > handle = le16_to_cpu(event_data->phy_entry[i].attached_dev_handle); > > 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
diff --git a/drivers/scsi/mpi3mr/mpi/mpi30_ioc.h b/drivers/scsi/mpi3mr/mpi/mpi30_ioc.h index 028784949873..ae74fccc65b8 100644 --- a/drivers/scsi/mpi3mr/mpi/mpi30_ioc.h +++ b/drivers/scsi/mpi3mr/mpi/mpi30_ioc.h @@ -453,9 +453,6 @@ struct mpi3_event_data_sas_notify_primitive { #define MPI3_EVENT_NOTIFY_PRIMITIVE_POWER_LOSS_EXPECTED (0x02) #define MPI3_EVENT_NOTIFY_PRIMITIVE_RESERVED1 (0x03) #define MPI3_EVENT_NOTIFY_PRIMITIVE_RESERVED2 (0x04) -#ifndef MPI3_EVENT_SAS_TOPO_PHY_COUNT -#define MPI3_EVENT_SAS_TOPO_PHY_COUNT (1) -#endif struct mpi3_event_sas_topo_phy_entry { __le16 attached_dev_handle; u8 link_rate; @@ -496,7 +493,7 @@ struct mpi3_event_data_sas_topology_change_list { u8 start_phy_num; u8 exp_status; u8 io_unit_port; - struct mpi3_event_sas_topo_phy_entry phy_entry[MPI3_EVENT_SAS_TOPO_PHY_COUNT]; + struct mpi3_event_sas_topo_phy_entry phy_entry[] __counted_by(num_entries); }; #define MPI3_EVENT_SAS_TOPO_ES_NO_EXPANDER (0x00)
Replace the deprecated[1] use of a 1-element array in struct mpi3_event_data_sas_topology_change_list with a modern flexible array. Additionally add __counted_by annotation since phy_entry is only ever accessed in loops controlled by num_entries. For example: for (i = 0; i < event_data->num_entries; i++) { ... handle = le16_to_cpu(event_data->phy_entry[i].attached_dev_handle); 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 Veerichetty <sathya.prakash@broadcom.com> Cc: Kashyap Desai <kashyap.desai@broadcom.com> Cc: Sumit Saxena <sumit.saxena@broadcom.com> Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com> Cc: "Martin K. Petersen" <martin.petersen@oracle.com> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> Cc: Ranjan Kumar <ranjan.kumar@broadcom.com> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Cc: mpi3mr-linuxdrv.pdl@broadcom.com Cc: linux-scsi@vger.kernel.org Cc: linux-hardening@vger.kernel.org --- drivers/scsi/mpi3mr/mpi/mpi30_ioc.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)