Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] igb: stale real queue counts after resume MSI fallback in __igb_open() --
commit 6c8e67bb8e01233489112f0bf629f1764d87d2c6 Author: Antonio Quartulli <[email protected]> igb: fix RTNL assertion when resuming from runtime suspend This commit skips calling netif_set_real_num_tx_queues() and netif_set_real_num_rx_queues() in __igb_open() when resuming is true to avoid triggering an RTNL assertion during runtime resume. > diff --git a/drivers/net/ethernet/intel/igb/igb_main.c > b/drivers/net/ethernet/intel/igb/igb_main.c > index 131df3e09ba14..bf8acac72b324 100644 > --- a/drivers/net/ethernet/intel/igb/igb_main.c > +++ b/drivers/net/ethernet/intel/igb/igb_main.c > @@ -4178,16 +4178,20 @@ static int __igb_open(struct net_device *netdev, bool > resuming) > if (err) > goto err_req_irq; > > - /* Notify the stack of the actual queue counts. */ > - err = netif_set_real_num_tx_queues(adapter->netdev, > - adapter->num_tx_queues); > - if (err) > - goto err_set_queues; > + /* Notify the stack of the actual queue counts. This needs RTNL, > + * which isn't held when resuming from runtime suspend. > + */ > + if (!resuming) { > + err = netif_set_real_num_tx_queues(adapter->netdev, > + adapter->num_tx_queues); > + if (err) > + goto err_set_queues; > > - err = netif_set_real_num_rx_queues(adapter->netdev, > - adapter->num_rx_queues); > - if (err) > - goto err_set_queues; > + err = netif_set_real_num_rx_queues(adapter->netdev, > + adapter->num_rx_queues); > + if (err) > + goto err_set_queues; > + } > > /* From here on the code is the same as igb_up() */ > clear_bit(__IGB_DOWN, &adapter->state); [Severity: Medium] Can leaving netdev->real_num_tx_queues and netdev->real_num_rx_queues stale when MSI-X falls back to MSI during resume cause concurrent unlocked TX on adapter->tx_ring[0] and a NULL pointer dereference in igb_xsk_pool_disable()? During suspend, __igb_shutdown() -> igb_clear_interrupt_scheme() frees all q_vectors and clears adapter->tx_ring[] and adapter->rx_ring[]. If MSI-X allocation fails on resume (including system resume via igb_resume() -> __igb_resume(dev, false), which already holds rtnl_lock() but still passes resuming = true), the driver falls back to MSI with adapter->num_tx_queues and adapter->num_rx_queues set to 1, allocating only index 0 while netdev->real_num_tx_queues and netdev->real_num_rx_queues remain at N > 1. In the TX path, the stack selects subqueues across 0 .. real_num_tx_queues - 1, each serialized only by its own netdev->_tx[q]._xmit_lock, but igb_tx_queue_mapping() folds all of them onto adapter->tx_ring[0]: drivers/net/ethernet/intel/igb/igb_main.c:igb_tx_queue_mapping() { unsigned int r_idx = skb->queue_mapping; if (r_idx >= adapter->num_tx_queues) r_idx = r_idx % adapter->num_tx_queues; return adapter->tx_ring[r_idx]; } CPU0 (subqueue 0) CPU1 (subqueue 1) netdev_start_xmit() netdev_start_xmit() HARD_TX_LOCK(dev, txq0) HARD_TX_LOCK(dev, txq1) igb_xmit_frame() igb_xmit_frame() igb_tx_queue_mapping() igb_tx_queue_mapping() -> adapter->tx_ring[0] -> adapter->tx_ring[0] igb_xmit_frame_ring(tx_ring[0]) igb_xmit_frame_ring(tx_ring[0]) first = &tx_ring-> first = &tx_ring-> tx_buffer_info[next_to_use] tx_buffer_info[next_to_use] <-- concurrent ring corruption Multiple CPUs transmitting on different subqueues concurrently run igb_xmit_frame_ring() and igb_tx_map() on adapter->tx_ring[0], corrupting tx_ring->next_to_use, tx_buffer_info, hardware descriptors, and BQL state. In addition, igb_xsk_pool_disable() checks xsk_get_pool_from_qid(), which validates qid against real_num_rx_queues and real_num_tx_queues; disabling an AF_XDP pool bound to qid >= 1 after a resume fallback passes qid to igb_txrx_ring_disable(), dereferencing NULL adapter->tx_ring[qid] and adapter->rx_ring[qid]. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1
