From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796259852; b=Fp2qXvSQBaVf1Si2rA0Ft6Ymd+1h1KgBHOH2YtA7G4W8wZxEO6Ak9lv0y0mNIIjqOOcT g9jekU1U+Ub9gEqvPoTWnRQ2q3iBar2+numXYIvZwBkyRg2Qwuzp65EMk6WQt9gE4MBfx 7dk2JxkA/OidGrV/4jJ1CG+/zv2krN6Mwt2NVzKYzy4wuKgJ2KuS7wwminknyIw75p3v7 DHRhM8glBunC/ORKjnmxvqhyAXUudDdCFnck5Pwo/vEGeWDGpIHXPTSWj+O1JQZML2H4T cY5BWaIJHG+TylVs+C7FU8WZft7rm8kWONfAVq5bgjfv+LdibqBXi7BI5O8NYUymTBg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796259852; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=jA6886b4KkKz4Hbjfu5BVWpwZiOhtpym0OZMyw7Utpo=; b=PeISRUx2KNE027V2B6/szknthyt7o6CObonEb/QolXFGkFh+8DnDoJSDyROsgSNrE59C Kc3Harq5kOECjfwpaWWAVqizeFF5gyi8wGMeDK/y9bK1TEt9bUE9bpIcfc3rvfReIvj4Z HH1EAC5gB8QHFyuYmANSn0iRqNwgEEAb7pffmctoH+IfUa72xKeCdEk//hJcBdWg3QpYD sBNfhskRFYiRWGurzSDFFhNqIfVqK8RBRoCaUN6ewAnknZ9GwRAsfwbt4PwlJMCaAnTUk wOedly23sF0AwRRzzfxCwnc1R9mWyyNMupbf6rZ+cIy8NKUDQZ1zQYPEjinI1KAV9uQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=i5hJLvtf; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03564606A322; Thu, 3 Dec 2026 01:04:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=i5hJLvtf Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CC831F00896; Thu, 3 Dec 2026 01:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796259851; bh=jA6886b4KkKz4Hbjfu5BVWpwZiOhtpym0OZMyw7Utpo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=i5hJLvtfusn580p2MmpXgehZ5EejbVDdyPThSw2ALiwcQ2h4dIqZsK6gk/y+2BlgF P1zAqzlCruYt9rarlu5pamUbzQuq48dMCiqmYTV0hLAOKIt/XnfWtwNLtrVsFw7MT0 6zZ+N18Q3SiltU3k1C6sLIR9CwCTTcXftraFa8O4GkzSFnQWXkYgLSU3BfO5yP0JGg m0j5Av7LFT8wAaRU3cqOeEdM+x9dt5noVJf65HluemgqsyDg1dYdR/YgCjaDNn3xul yTpEre8XOlenz2A9r8PEVISlX31/XZz9Rs1SH5RYDeTfQ0GURINjnrjhuYpT18TZHK aFZ5mFafNKrbA== Subject: Re: [PATCH net v7 2/7] igb: don't touch rings that don't exist when disabling an XSK pool From: netdev-bot+sashiko@kernel.org To: antonio@mandelbit.com Cc: intel-wired-lan@lists.osuosl.org, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, janislacis06@gmail.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me, sriram.yagnaraman@ericsson.com, kurt@linutronix.de, maciej.fijalkowski@intel.com, hkallweit1@gmail.com, joe@dama.to, rafael@kernel.org, sven.auhagen@voleatech.de, netdev@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, stable@vger.kernel.org Date: Thu, 03 Dec 2026 01:04:09 +0000 Message-ID: <179625984965.3146.15250464225643049078@kernel.org> In-Reply-To: <20261202002317.3140591-3-antonio@mandelbit.com> References: <20261202002317.3140591-3-antonio@mandelbit.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 (1) · Medium: 1 (4) · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] At this commit, the new `qid < adapter->num_rx_queues` guard in igb_xsk_pool_disable() and the num_tx_queues check in… Pre-existing issues: - [High] This problem wasn't introduced by this patch, but the patch rewrites these exact blocks and keeps the faulty assumption. - [Medium] At this commit, igb_xsk_pool_disable() decides whether to tear down and rebuild the queue with only `netif_running() &&… - [Medium] This problem wasn't introduced by this patch, but igb_xsk_wakeup() rejects any qid >= adapter->num_tx_queues and… - [Medium] This problem wasn't introduced by this patch, but in igb_xsk_pool_disable(), if igb_realloc_rx_buffer_info(rx_ring, false)… - [Medium] This problem wasn't introduced by this patch, but igb_txrx_ring_disable() clears RXDCTL/TXDCTL with posted MMIO writes. -- igb: don't touch rings that don't exist when disabling an XSK pool This patch adds igb_xsk_tx_ring(), which returns NULL for a qid beyond num_tx_queues. igb_txrx_ring_disable() and igb_txrx_ring_enable() now skip the Tx part when there is no Tx ring. igb_xsk_pool_disable() also skips the ring teardown entirely when qid >= num_rx_queues, which covers 82576 with VFs and the runtime suspended case. Link: https://lore.kernel.org/netdev/20261116153041.3002666-2-antonio@mandelbit.com/ > diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c b/drivers/net/ethernet/intel/igb/igb_xsk.c > index ce4a7b58cad2f..b6234e349ef20 100644 > --- a/drivers/net/ethernet/intel/igb/igb_xsk.c > +++ b/drivers/net/ethernet/intel/igb/igb_xsk.c > @@ -31,15 +31,22 @@ static int igb_realloc_rx_buffer_info(struct igb_ring *ring, bool pool_present) > return 0; > } > > +/* With VFs, the device has a single Tx queue but can have more Rx queues */ > +static struct igb_ring *igb_xsk_tx_ring(struct igb_adapter *adapter, u16 qid) > +{ > + return qid < adapter->num_tx_queues ? adapter->tx_ring[qid] : NULL; > +} [Severity: Medium] This is a pre-existing issue, but with this helper an Rx-only queue can now keep a zero-copy pool. How does igb_xsk_wakeup() handle such a queue? igb_xsk_wakeup() { ... if (qid >= adapter->num_tx_queues) return -EINVAL; ring = adapter->tx_ring[qid]; if (!READ_ONCE(ring->xsk_pool)) return -EINVAL; ... } Take the scenario from the commit message: a pool is bound to queue 1, then VFs are enabled, so num_tx_queues == 1. igb_configure_rx_ring() re-attaches the pool to rx_ring[1]. But every ndo_xsk_wakeup for queue 1 returns -EINVAL before the XDP_WAKEUP_RX branch. Does that mean the Rx need_wakeup kick never reaches rx_ring[1]->q_vector? The two paths also check the qid against different counters. igb_xsk_pool_enable() uses netdev->real_num_tx_queues and adapter->num_rx_queues, while igb_xsk_wakeup() uses adapter->num_tx_queues. Should these agree? > + > static void igb_txrx_ring_disable(struct igb_adapter *adapter, u16 qid) > { > - struct igb_ring *tx_ring = adapter->tx_ring[qid]; > + struct igb_ring *tx_ring = igb_xsk_tx_ring(adapter, qid); > struct igb_ring *rx_ring = adapter->rx_ring[qid]; > struct e1000_hw *hw = &adapter->hw; > > - set_bit(IGB_RING_FLAG_TX_DISABLED, &tx_ring->flags); > - > - wr32(E1000_TXDCTL(tx_ring->reg_idx), 0); > + if (tx_ring) { > + set_bit(IGB_RING_FLAG_TX_DISABLED, &tx_ring->flags); > + wr32(E1000_TXDCTL(tx_ring->reg_idx), 0); > + } > wr32(E1000_RXDCTL(rx_ring->reg_idx), 0); > > synchronize_net(); [Severity: Medium] This isn't a bug introduced by this patch, but these queue disables are posted MMIO writes that are never flushed or polled. Are synchronize_net() and napi_disable() enough to make sure the queue has stopped DMA? The rings are cleaned right after, and igb_xsk_pool_disable() then calls xsk_pool_dma_unmap(). igb_down() in the same driver does this after disabling Rx and Tx: /* flush both disables and wait for them to finish */ wrfl(); usleep_range(10000, 11000); igb_rx_fifo_flush_82575() also polls RXDCTL. If the queue hasn't actually stopped, could a late descriptor write-back or packet DMA land in a UMEM buffer already returned to the pool? Could it hit an IOVA that was just unmapped? > @@ -47,24 +54,27 @@ static void igb_txrx_ring_disable(struct igb_adapter *adapter, u16 qid) > /* Rx/Tx share the same napi context. */ > napi_disable(&rx_ring->q_vector->napi); > > - igb_clean_tx_ring(tx_ring); > + if (tx_ring) { > + igb_clean_tx_ring(tx_ring); > + memset(&tx_ring->tx_stats, 0, sizeof(tx_ring->tx_stats)); > + } [Severity: High] This is a pre-existing issue, but since these blocks are being rewritten: does the "Rx/Tx share the same napi context" assumption hold when IGB_FLAG_QUEUE_PAIRS is clear? igb_set_flag_queue_pairs() never sets the flag on 82575/i211. On 82576/82580/i350/i354/i210 it clears the flag when rss_queues <= max_rss_queues / 2. With the flag clear, igb_set_interrupt_capability() reserves separate Tx vectors. igb_alloc_q_vectors() then puts rx_ring[qid] and tx_ring[qid] on different q_vectors. The driver's own igb_xsk_wakeup() treats the sharing as conditional: /* If IGB_FLAG_QUEUE_PAIRS is active, the q_vector * and NAPI is shared between RX and TX. Only rx_ring->q_vector->napi is disabled here. Can the Tx vector keep running this: igb_poll() igb_clean_tx_irq(q_vector, budget) while this path runs igb_clean_tx_ring(tx_ring) on the same ring? IGB_RING_FLAG_TX_DISABLED only stops igb_xmit_zc() and igb_xmit_frame_ring(), not the completion loop. Both loops start from tx_ring->next_to_clean. Could skbs or xdp frames be freed twice, or the same DMA mapping be unmapped twice? Could netdev_tx_reset_queue() race netdev_tx_completed_queue() and hit this BUG_ON in dql_completed(): BUG_ON(count > num_queued - dql->num_completed); There is a related problem in igb_txrx_ring_enable(). igb_configure_tx_ring() resets TDH/TDT and memsets tx_buffer_info while the Tx NAPI is still live. Could this also napi_disable()/napi_enable() tx_ring->q_vector->napi when it differs from the Rx one? This is unchanged at the end of the series. [ ... ] > @@ -148,7 +158,13 @@ static int igb_xsk_pool_disable(struct igb_adapter *adapter, u16 qid) > return -EINVAL; > > rx_ring = adapter->rx_ring[qid]; > - if_running = netif_running(adapter->netdev) && igb_xdp_is_enabled(adapter); > + /* The stack can know more queues than the device has, e.g. while > + * runtime suspended, which frees the rings: skip the rings it > + * doesn't have. > + */ > + if_running = netif_running(adapter->netdev) && > + igb_xdp_is_enabled(adapter) && > + qid < adapter->num_rx_queues; [Severity: Medium] This is a pre-existing issue rather than something introduced here. The new gate catches a missing ring, but not a ring that exists and has no resources. What happens if __igb_open() failed earlier? That can happen in __igb_resume(), or after igb_close() in igb_xdp_setup(), igb_sriov_reinit() or igb_reinit_queues(). The __igb_open() unwind frees ring->desc and the tx/rx buffer_info arrays. It leaves these in place: - num_rx_queues > 0 - the ring structs, still allocated - __LINK_STATE_START, still set - the NAPI, never enabled Closing a zero-copy socket in that state still calls igb_txrx_ring_disable(). netif_napi_add() left SCHED|NPSVC set, so wouldn't napi_disable() spin forever with RTNL held? If it got past that, igb_txrx_ring_enable() would dereference NULL in two places: - igb_configure_tx_ring(), in the memset of tx_buffer_info - igb_configure_rx_ring(), at IGB_RX_DESC(ring, 0) igb_xsk_pool_enable() has the same gap. The later patch in this series, "igb: resume the device before changing XDP or XSK settings", seems to fix both paths: - it adds "&& rx_ring->desc" to this gate - igb_xsk_pool_enable() returns -ENODEV when !adapter->rx_ring[qid]->desc - a runtime PM reference is held across igb_xdp() [Severity: Medium] Can this check, and the num_tx_queues check in igb_xsk_tx_ring(), change under a concurrent runtime resume? This path holds only RTNL. __igb_resume() with rpm=true does not take RTNL. It rebuilds num_rx_queues, num_tx_queues and adapter->rx_ring[]/tx_ring[] through igb_init_interrupt_scheme(). igb_set_interrupt_capability() publishes the count first: adapter->num_rx_queues = adapter->rss_queues; The ring pointers are only filled in later by igb_alloc_q_vector(), and NAPI is enabled later still, in __igb_open(). rx_ring is also loaded before num_rx_queues is checked. Suppose a zero-copy socket is closed during that window. Could this check pass and the code still dereference a NULL rx_ring? Could it call napi_disable() on a NAPI that isn't enabled yet and spin with RTNL held? The later patch in this series, "igb: resume the device before changing XDP or XSK settings", appears to close this. It calls pm_runtime_get_sync() in igb_xdp() before igb_xsk_pool_setup(). > if (if_running) > igb_txrx_ring_disable(adapter, qid); > [Severity: Medium] This isn't a bug introduced by this patch, but look further down in igb_xsk_pool_disable(): if (if_running) { err = igb_realloc_rx_buffer_info(rx_ring, false); if (err) return err; igb_txrx_ring_enable(adapter, qid); } When igb_realloc_rx_buffer_info() fails, igb_txrx_ring_disable() and xsk_pool_dma_unmap() have already run, but igb_txrx_ring_enable() is skipped. Doesn't that leave the queue in this state? - RXDCTL/TXDCTL at 0 - IGB_RING_FLAG_TX_DISABLED set - the q_vector NAPI disabled - rx_ring->xsk_pool and tx_ring->xsk_pool pointing at a pool that the XSK core then frees The next igb_down() would then disable the same NAPI again: igb_down() napi_disable(&adapter->q_vector[i]->napi) That call never returns, and RTNL stays held. igb_xsk_pool_enable() has the same pattern: on a realloc failure it only unmaps the pool and returns. This is unchanged at the end of the series. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202002317.3140591-1-antonio%40mandelbit.com