Commit 4a8842de authored by Tomas Henzl's avatar Tomas Henzl Committed by Martin K. Petersen

scsi: mpt3sas: fix an out of bound write

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: 1d55abc0 ("scsi: mpt3sas: switch to pci_alloc_irq_vectors")
Signed-off-by: default avatarTomas Henzl <thenzl@redhat.com>
Acked-by: default avatarSuganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent a2390348
...@@ -2410,9 +2410,12 @@ _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc) ...@@ -2410,9 +2410,12 @@ _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc)
continue; 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; ioc->cpu_msix_table[cpu] = reply_q->msix_index;
} }
}
return; return;
} }
cpu = cpumask_first(cpu_online_mask); cpu = cpumask_first(cpu_online_mask);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment