Skip to content

Commit 586b410

Browse files
thenzlgregkh
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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 44958ca commit 586b410

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
@@ -1355,11 +1355,21 @@ static struct mpi3mr_sas_port *mpi3mr_sas_port_add(struct mpi3mr_ioc *mrioc,
13551355
mpi3mr_sas_port_sanity_check(mrioc, mr_sas_node,
13561356
mr_sas_port->remote_identify.sas_address, hba_port);
13571357

1358+
if (mr_sas_node->num_phys > sizeof(mr_sas_port->phy_mask) * 8)
1359+
ioc_info(mrioc, "max port count %u could be too high\n",
1360+
mr_sas_node->num_phys);
1361+
13581362
for (i = 0; i < mr_sas_node->num_phys; i++) {
13591363
if ((mr_sas_node->phy[i].remote_identify.sas_address !=
13601364
mr_sas_port->remote_identify.sas_address) ||
13611365
(mr_sas_node->phy[i].hba_port != hba_port))
13621366
continue;
1367+
1368+
if (i > sizeof(mr_sas_port->phy_mask) * 8) {
1369+
ioc_warn(mrioc, "skipping port %u, max allowed value is %lu\n",
1370+
i, sizeof(mr_sas_port->phy_mask) * 8);
1371+
goto out_fail;
1372+
}
13631373
list_add_tail(&mr_sas_node->phy[i].port_siblings,
13641374
&mr_sas_port->phy_list);
13651375
mr_sas_port->num_phys++;

0 commit comments

Comments
 (0)