Skip to content

Commit

Permalink
scsi: mpt3sas: fix an out of bound write
Browse files Browse the repository at this point in the history
cpu_msix_table is allocated to store online cpus, but pci_irq_get_affinity
may return cpu_possible_mask which is then used to access cpu_msix_table.
That causes bad user experience.  Fix limits access to only online cpus,
I've also added an additional test to protect from an unlikely change in
cpu_online_mask.

[mkp: checkpatch]

Fixes: 1d55abc ("scsi: mpt3sas: switch to pci_alloc_irq_vectors")
Signed-off-by: Tomas Henzl <[email protected]>
Acked-by: Suganath Prabu Subramani <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
  • Loading branch information
thenzl authored and martinkpetersen committed Jan 31, 2018
1 parent a239034 commit 4a8842d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/scsi/mpt3sas/mpt3sas_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -2410,8 +2410,11 @@ _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc)
continue;
}

for_each_cpu(cpu, mask)
for_each_cpu_and(cpu, mask, cpu_online_mask) {
if (cpu >= ioc->cpu_msix_table_sz)
break;
ioc->cpu_msix_table[cpu] = reply_q->msix_index;
}
}
return;
}
Expand Down

0 comments on commit 4a8842d

Please sign in to comment.