The number of XDPSQs is calculated by libeth as either nr_cpu_ids or
the number of RQs if the latter is bigger. In this case, although
it's pretty hard to achieve on idpf, passing XDPSQ index to
cpu_to_mem() directly would trigger out-of-bound read of
percpu data.
Wrap the index by nr_cpu_ids just in case when picking the closest
node with memory to allocate cleanup timers.
Found by Sashiko.
Fixes: ac8a861f632e ("idpf: prepare structures to support XDP")
Cc: [email protected] # 6.18+
Signed-off-by: Alexander Lobakin <[email protected]>
---
drivers/net/ethernet/intel/idpf/xdp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/idpf/xdp.c
b/drivers/net/ethernet/intel/idpf/xdp.c
index 48320ea004df..e6e425625f04 100644
--- a/drivers/net/ethernet/intel/idpf/xdp.c
+++ b/drivers/net/ethernet/intel/idpf/xdp.c
@@ -164,7 +164,7 @@ int idpf_xdpsqs_get(const struct idpf_vport *vport)
for (u32 i = 0; i < vport->num_xdp_txq; i++) {
timers[i] = kzalloc_node(sizeof(*timers[i]), GFP_KERNEL,
- cpu_to_mem(i));
+ cpu_to_mem(i % nr_cpu_ids));
if (!timers[i]) {
for (int j = i - 1; j >= 0; j--)
kfree(timers[j]);
--
2.56.1