Skip to content

Commit e58970e

Browse files
mngyadamabuehaze14
authored andcommitted
scsi: mpi3mr: Sanitise num_phys
[ Upstream commit 3668651 ] Information is stored in mr_sas_port->phy_mask, values larger then size of this field shouldn't be allowed. Signed-off-by: Tomas Henzl <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Sathya Prakash Veerichetty <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]> [patched it to the out-of-tree mpi3mr driver] Signed-off-by: Mahmoud Adam <[email protected]>
1 parent a7591eb commit e58970e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/scsi/mpi3mr/mpi3mr_transport.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,11 +1082,21 @@ static struct mpi3mr_sas_port * mpi3mr_sas_port_add(struct mpi3mr_ioc *mrioc,
10821082
mpi3mr_sas_port_sanity_check(mrioc, mr_sas_node,
10831083
mr_sas_port->remote_identify.sas_address, hba_port);
10841084

1085+
if (mr_sas_node->num_phys > sizeof(mr_sas_port->phy_mask) * 8)
1086+
ioc_info(mrioc, "max port count %u could be too high\n",
1087+
mr_sas_node->num_phys);
1088+
10851089
for (i = 0; i < mr_sas_node->num_phys; i++) {
10861090
if ((mr_sas_node->phy[i].remote_identify.sas_address !=
10871091
mr_sas_port->remote_identify.sas_address) ||
10881092
(mr_sas_node->phy[i].hba_port != hba_port))
10891093
continue;
1094+
1095+
if (i > sizeof(mr_sas_port->phy_mask) * 8) {
1096+
ioc_warn(mrioc, "skipping port %u, max allowed value is %lu\n",
1097+
i, sizeof(mr_sas_port->phy_mask) * 8);
1098+
goto out_fail;
1099+
}
10901100
list_add_tail(&mr_sas_node->phy[i].port_siblings,
10911101
&mr_sas_port->phy_list);
10921102
mr_sas_port->num_phys++;

0 commit comments

Comments
 (0)