* [PATCH net v2 0/1] netdevsim: bound the peer TX queue index in nsim_start_peer_tx_queue()
@ 2026-11-21 19:32 Kyuwon Cho
2026-11-21 19:32 ` [PATCH net v2 1/1] " Kyuwon Cho
0 siblings, 1 reply; 2+ messages in thread
From: Kyuwon Cho @ 2026-11-21 19:32 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Breno Leitao, Andrew Lunn, David S. Miller, Eric Dumazet,
Paolo Abeni, netdev, linux-kernel
nsim_start_peer_tx_queue() can wake a TX queue past the end of the
peer's TX queue array after the device is relinked to a peer with fewer
TX queues; KASAN reports a slab-out-of-bounds read in nsim_poll(). The
patch skips the wake-up in that case.
v2: send the patch inline instead of as an attachment (Jakub).
v1: https://lore.kernel.org/netdev/179505710275.3511681.13434978152402269948@gmail.com/
The patch was written with LLM assistance; we reviewed and tested it.
With it, the reproducer from v1 no longer triggers the KASAN report.
Kyuwon Cho (1):
netdevsim: bound the peer TX queue index in nsim_start_peer_tx_queue()
drivers/net/netdevsim/netdev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH net v2 1/1] netdevsim: bound the peer TX queue index in nsim_start_peer_tx_queue()
2026-11-21 19:32 [PATCH net v2 0/1] netdevsim: bound the peer TX queue index in nsim_start_peer_tx_queue() Kyuwon Cho
@ 2026-11-21 19:32 ` Kyuwon Cho
0 siblings, 0 replies; 2+ messages in thread
From: Kyuwon Cho @ 2026-11-21 19:32 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Breno Leitao, Andrew Lunn, David S. Miller, Eric Dumazet,
Paolo Abeni, netdev, linux-kernel
nsim_start_peer_tx_queue() wakes the peer's TX queue with the index of
the RX queue being polled, and only compares this device's TX queue
count with the peer's RX queue count. When the device is relinked to a
peer with fewer TX queues while its RX queues still hold traffic from
the old peer, the index is past the peer's TX queue array:
BUG: KASAN: slab-out-of-bounds in nsim_poll (include/linux/netdevice.h:3834 drivers/net/netdevsim/netdev.c:60)
Read of size 8
Call Trace:
<IRQ>
nsim_poll (drivers/net/netdevsim/netdev.c:409)
__napi_poll.constprop.0 (net/core/dev.c:7997)
net_rx_action (net/core/dev.c:8217)
Skip the wake-up when the index is not a TX queue of the peer.
Fixes: ff2ac4df58ad ("netdevsim: implement peer queue flow control")
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
---
drivers/net/netdevsim/netdev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
index eebc02ccc4a9..6e287ae692a8 100644
--- a/drivers/net/netdevsim/netdev.c
+++ b/drivers/net/netdevsim/netdev.c
@@ -53,7 +53,8 @@ static void nsim_start_peer_tx_queue(struct net_device *dev, struct nsim_rq *rq)
/* TX device */
peer_dev = peer_ns->netdev;
- if (dev->real_num_tx_queues != peer_dev->num_rx_queues)
+ if (dev->real_num_tx_queues != peer_dev->num_rx_queues ||
+ idx >= peer_dev->real_num_tx_queues)
goto out;
txq = netdev_get_tx_queue(peer_dev, idx);
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-21 19:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-21 19:32 [PATCH net v2 0/1] netdevsim: bound the peer TX queue index in nsim_start_peer_tx_queue() Kyuwon Cho
2026-11-21 19:32 ` [PATCH net v2 1/1] " Kyuwon Cho
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®