Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.10.208.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796171013; b=2kAnQV0KxYnmlePWoFEb6/qIvSnZXIjH7HPDE5hIEy9uO0U74ecgPhG4mlBE5A8UsE8f UN2Q24smUjKQfjGKXkllbdvv/O+ISeAEqfk0ppqQtdtYfjw0DA61+NnvTmSDROKwf9FEv 1/+rxX/NSdUYzjpZgLP2PBzyFgloR1NEGhybDWB/CAwYka7E7QR0Fi8TUsG9OGBxVnIw+ s78xuo6vqFLc3fgYyaXlADLHZcRxqRRui9kHDkrUGjsx+Gr/rBvcEZz+RnO5vQLS4F2vu l7il7eDfyuyxJsbiPrbIQpii3DRnORzZ+EYuLD8mZX+/4j/C7k1krf7K4srtbBAdeiw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796171013; h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Rspamd-Queue-Id; bh=eVJ/+OrFfNzubCwGgh0Sm6C1GkO0KqHXsHtT4a1/jnU=; b=RSVjL0fplWzeOd0KbpE+2gwRRaEUtxVXXH2ZqZRP0/TPnmNMzSwyTYd49IyNmofPNxk0 QjbNaIn/z2mJk/8ThDx0n+4BUf08HMD2/o1Mf1K1pnscx6o+fDynfwH+mPCHLCUL5Qg1X GvhrFf43v2kpEpZ+Adm3oUJRATTUe+brnIj5zDl8umMdZEhNfSM3spx8zMz99NtgceEkc u3tjd3nGnHu44ezdkBsenxVZFuEWOSWijYuwenuEuyrEFPvnVp7WGsIOUz4yXKvaax7q0 wWTjMgxRYzKIHJkVoBw8eajeDrCklI8COL5PZxtWfBYyioI/daRKPDAsyrzObpjos2g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=mandelbit.com; spf=pass smtp.mailfrom=mandelbit.com; dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=FTKvoj2R; arc=none smtp.remote-ip=195.10.208.42 Received: from mout-b-112.mailbox.org (mout-b-112.mailbox.org [195.10.208.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B8FB606A69D; Wed, 2 Dec 2026 00:23:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9B8FB606A69D Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mandelbit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mandelbit.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=FTKvoj2R Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-112.mailbox.org (Postfix) with ESMTPS id 4jfJQ26mX3z5vvY; Wed, 02 Dec 2026 01:23:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1796171003; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eVJ/+OrFfNzubCwGgh0Sm6C1GkO0KqHXsHtT4a1/jnU=; b=FTKvoj2Rv4uM2pqdepcYdUWxfJB/EjfvSqAhTz/FJP8ViEdFCXSk0TjYmvZ0hhE7deN1sj VlW0RAg7R0lsJvtLYxApaJAtAx+EE+lvRBuzmYceSCcxBT8O4AxrHNj2yWhll6aOa+AaXB jSzx30z1vRiUpZ/zlkP9Hp0YJAt+zq56AFrChVwQzmPR4hr7P4PMkpC5XvnAwZw9dARyg3 6xeLEJVolGqppBRIWlqo0914z0ExIm5Q9hmVp4dIn8QSyvSclkg7nvpFP/r/Ck3ugp1uDk 80OOzS5OoKGzlvkRikjn2uZFV72vfdYcM1WasjjBFOXSlq+pFOcOmqMaRM5c3w== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of antonio@mandelbit.com designates 2001:67c:2050:b231:465::1 as permitted sender) smtp.mailfrom=antonio@mandelbit.com From: Antonio Quartulli To: intel-wired-lan@lists.osuosl.org Cc: Antonio Quartulli , Tony Nguyen , Przemek Kitszel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Janis Edvarts Lacis , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Sriram Yagnaraman , Kurt Kanzenbach , Maciej Fijalkowski , Heiner Kallweit , Joe Damato , "Rafael J. Wysocki" , Sven Auhagen , netdev@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net v7 2/7] igb: don't touch rings that don't exist when disabling an XSK pool Date: Wed, 2 Dec 2026 01:23:10 +0100 Message-ID: <20261202002317.3140591-3-antonio@mandelbit.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261202002317.3140591-1-antonio@mandelbit.com> References: <20261202002317.3140591-1-antonio@mandelbit.com> X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4jfJQ26mX3z5vvY xsk_get_pool_from_qid() checks the queue id against the stack's real queue counts, which can be higher than the number of rings the device has: on 82576, enabling VFs leaves a single Tx queue while keeping two Rx queues, and a runtime suspend frees all rings. Disabling the pool of such a queue, e.g. one bound to queue 1 before enabling VFs, then passes a NULL Tx ring to igb_txrx_ring_disable(), and a NULL Rx ring too if the socket is closed while the device is runtime suspended. Only disable and re-enable the rings the device has: skip the queue if it has no Rx ring, and only the Tx part if it has no Tx ring, so that an Rx ring using the pool still stops using it. Tested with the 82576 emulated by QEMU and a zero-copy AF_XDP socket on queue 1: closing it after enabling a VF no longer oopses and the Rx ring no longer references the pool afterwards (checked with a debug print, as QEMU doesn't spread traffic over the PF queues with VFs), and without VFs queue 1 keeps receiving after the close. Not run under KASAN. Fixes: 80f6ccf9f116 ("igb: Introduce XSK data structures and helpers") Cc: stable@vger.kernel.org # 6.14+ Link: https://lore.kernel.org/netdev/20261116153041.3002666-2-antonio@mandelbit.com/ Reviewed-by: Janis Edvarts Lacis Signed-off-by: Antonio Quartulli --- v7: no changes v6: the message and comment name the runtime suspended case instead of the MSI fallback, which only reaches this check with patch 4 (Sashiko); no code changes v5: the message also mentions the runtime suspended case (no code changes) v4: also handle queues with an Rx but no Tx ring, as with VFs (Sashiko): tear down the Rx ring and skip only the Tx part; tested with a zero-copy AF_XDP socket; subject was "don't disable rings that don't exist ..." v3: new patch. drivers/net/ethernet/intel/igb/igb_xsk.c | 38 +++++++++++++++++------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c b/drivers/net/ethernet/intel/igb/igb_xsk.c index ce4a7b5..b6234e3 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; +} + 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(); @@ -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)); + } igb_clean_rx_ring(rx_ring); - memset(&rx_ring->rx_stats, 0, sizeof(rx_ring->rx_stats)); - memset(&tx_ring->tx_stats, 0, sizeof(tx_ring->tx_stats)); } static void igb_txrx_ring_enable(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]; - igb_configure_tx_ring(adapter, tx_ring); + if (tx_ring) + igb_configure_tx_ring(adapter, tx_ring); igb_configure_rx_ring(adapter, rx_ring); synchronize_net(); - clear_bit(IGB_RING_FLAG_TX_DISABLED, &tx_ring->flags); + if (tx_ring) + clear_bit(IGB_RING_FLAG_TX_DISABLED, &tx_ring->flags); /* call igb_desc_unused which always leaves * at least 1 descriptor unused to make sure @@ -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; if (if_running) igb_txrx_ring_disable(adapter, qid); -- 2.56.1