Re: 回复: [PATCH] scsi: mpt3sas: Fix invalid NUMA node index

From: John Garry
Date: Fri Jan 02 2026 - 05:34:41 EST


On 31/12/2025 01:19, vulab@xxxxxxxxxxx wrote:
Hi John,

Thank you for the feedback.

Regarding the suggestion to audit all cpumask_of_node() implementations:

I noticed that a very similar issue was recently fixed in the
megaraid_sas driver (commit 752eb816b55a, "scsi: megaraid_sas: Fix
invalid node index"), where an UBSAN array-index-out-of-bounds warning
was addressed by handling NUMA_NO_NODE locally in the driver.

Following that approach, it seems reasonable for mpt3sas to handle
this case locally as well, while leaving any broader unification of
cpumask_of_node() semantics across architectures as a separate
discussion, since changes in the x86 topology headers may have wider
impact.

Regarding the fallback behavior:

The existing megaraid_sas fix falls back to node 0, but as you pointed
out, some implementations (e.g. drivers/base/arch_numa.c) treat
NUMA_NO_NODE as indicating no specific NUMA locality and return
cpu_all_mask. Forcing node 0 in this case may unnecessarily constrain
interrupt affinity on NUMA systems.

For a v2, I propose to:


1.
Fix the issue locally in the mpt3sas driver (similar to

megaraid_sas); and


1.
Use cpu_online_mask as the fallback when dev_to_node() returns

NUMA_NO_NODE, to better match the intended semantics, while still
preventing out-of-bounds access.

Please let me know if this sounds acceptable.

I am not the driver maintainer, so it is not my choice.

But I will try to remedy this in the per-arch code if you don't want to.