Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but incorrect subtraction in the fall_back path causes unassigned CPUs in the msix table and a potential divide by zero if nr_msix evaluates to zero.
--
commit 9e90c3b985462523aebc40d2af67de713d3be849
Author: Ivy Lopez <[email protected]>
scsi: mpt3sas: avoid out-of-bounds cpumask_of_node() call in _base_assign_reply_queues()
dev_to_node() can return NUMA_NO_NODE (-1) on systems without NUMA
topology information for the PCI device, such as single-socket
boards that don't expose device-to-node affinity. Fall back to
cpu_online_mask when no NUMA node is available, rather than assuming
dev_to_node() always returns a valid node index.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=221294
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
> index fed7aeffec58d..1af25a22611a1 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
> @@ -3238,7 +3238,10 @@ _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc)
> * corresponding to high iops queues.
> */
> if (ioc->high_iops_queues) {
> - mask = cpumask_of_node(dev_to_node(&ioc->pdev->dev));
> + int node = dev_to_node(&ioc->pdev->dev);
> +
> + mask = (node == NUMA_NO_NODE) ?
> + cpu_online_mask : cpumask_of_node(node);
> for (index = 0; index < ioc->high_iops_queues;
> index++) {
> irq = pci_irq_vector(ioc->pdev, index);
[Severity: High]
This isn't a bug introduced by this patch, but incorrect subtraction in the
fall_back path causes unassigned CPUs in the msix table and a potential
divide by zero.
In _base_assign_reply_queues(), the calculation evaluates incorrectly:
drivers/scsi/mpt3sas/mpt3sas_base.c:_base_assign_reply_queues() {
...
fall_back:
cpu = cpumask_first(cpu_online_mask);
nr_msix -= (ioc->high_iops_queues - iopoll_q_count);
index = 0;
list_for_each_entry(reply_q, &ioc->reply_queue_list, list) {
unsigned int i, group = nr_cpus / nr_msix;
...
}
If iopoll_q_count > 0, the calculation nr_msix -= (ioc->high_iops_queues -
iopoll_q_count) evaluates to nr_msix - high_iops_queues + iopoll_q_count.
This mathematically adds iopoll_q_count instead of subtracting it, inflating
nr_msix. This causes group = nr_cpus / nr_msix to calculate a smaller group
size, leaving trailing CPUs mapped to vector 0.
Furthermore, if PCI MSI-X allocation limits nr_msix to exactly
high_iops_queues (e.g. system interrupt limits), nr_msix evaluates to 0.
This would trigger a hardware divide-by-zero exception when evaluating
nr_cpus / nr_msix.
Is it possible to rewrite this subtraction to avoid inflating nr_msix and
prevent a potential divide-by-zero?
--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.