🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #7359

Re: [PATCH net] igc: track rx frame boundaries independent of skbs

#7359
From: netdev-bot+sashiko
Date: Mon, 26 Oct 2026 07:43
188 lines
15472 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 (2) · Medium: 1 · 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] The new split-frame discard paths leave frames out of
  rx_packets and rx_bytes, which contradicts the rtnl_link_stats64…

Pre-existing issues:
- [High] In igc_clean_rx_irq(), the FPE mPacket early exit leaks the RX
  page and its DMA mapping.
- [High] igc_xdp_set_prog(), igc_xdp_enable_pool() and
  igc_xdp_disable_pool() tear down and rebuild the RX ring while NAPI…

--

igc: track rx frame boundaries independent of skbs

The patch adds a per-ring rx_in_frame flag so the inline TSIP timestamp
header is stripped only from the first buffer of a frame. Split frames
that are not supported (XDP enabled, AF_XDP zero-copy) are rejected
before XDP runs, and their continuation descriptors are drained. The RX
poll functions now return a work_done count that includes discarded
descriptors, instead of total_packets.

> diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
> index 1fb5f3cbe93c5..9ca5558c762c9 100644
> --- a/drivers/net/ethernet/intel/igc/igc_main.c
> +++ b/drivers/net/ethernet/intel/igc/igc_main.c
> @@ -474,6 +474,7 @@ static void igc_clean_rx_ring(struct igc_ring *ring)
>  		igc_clean_rx_ring_page_shared(ring);
>  
>  	clear_ring_uses_large_buffer(ring);
> +	ring->rx_in_frame = false;
>  
>  	ring->next_to_alloc = 0;
>  	ring->next_to_clean = 0;
> @@ -673,6 +674,7 @@ static void igc_configure_rx_ring(struct igc_adapter *adapter,
>  	/* reset next-to- use/clean to place SW in sync with hardware */
>  	ring->next_to_clean = 0;
>  	ring->next_to_use = 0;
> +	ring->rx_in_frame = false;
>  
>  	if (ring->xsk_pool)
>  		buf_size = xsk_pool_get_rx_frame_size(ring->xsk_pool);

[Severity: High]
This isn't a bug introduced by this patch, but these new resets assume
NAPI is not polling the ring. Do the XDP reconfiguration paths actually
guarantee that?

igc_xdp_set_prog(), igc_xdp_enable_pool() and igc_xdp_disable_pool() all
clean the ring before they disable NAPI:

drivers/net/ethernet/intel/igc/igc_xdp.c:igc_xdp_set_prog() {
    ...
		for (i = 0; i < adapter->num_rx_queues; i++) {
			igc_disable_rx_ring(adapter->rx_ring[i]);
			igc_disable_tx_ring(adapter->tx_ring[i]);
			napi_disable(&adapter->rx_ring[i]->q_vector->napi);
		}
    ...
			napi_enable(&adapter->rx_ring[i]->q_vector->napi);
			igc_enable_tx_ring(adapter->tx_ring[i]);
			igc_enable_rx_ring(adapter->rx_ring[i]);
    ...
}

igc_disable_rx_ring() does only an RXDCTL write before it calls
igc_clean_rx_ring(). Also, napi_enable() runs before
igc_enable_rx_ring()->igc_configure_rx_ring().

Suppose igc_clean_rx_irq() is running on another CPU while
igc_clean_rx_ring_page_shared() calls dev_kfree_skb(rx_ring->skb) and
drains the pages. Could the poll then call igc_add_rx_frag() on the freed
skb, or drop page references a second time through igc_put_rx_buffer()?

When the poll exits, it also writes rx_ring->skb, next_to_clean and
rx_in_frame back, after the reset. igc_configure_rx_ring() resets
rx_in_frame but not rx_ring->skb. A later poll could then see
first == true with a stale non-NULL skb, and the new (!first && !skb)
check would not catch that.

Triggering this needs a CAP_NET_ADMIN user to attach or detach an XDP
program, or to bind or unbind an AF_XDP pool while XDP is loaded, while
RX traffic keeps a poll running on another CPU.

[ ... ]

> @@ -2635,21 +2635,34 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget)
>  		dma_rmb();
>  
>  		rx_buffer = igc_get_rx_buffer(rx_ring, size, &rx_buffer_pgcnt);
> +		tsip = first && igc_test_staterr(rx_desc, IGC_RXDADV_STAT_TSIP);
> +
> +		if ((!first && !skb) ||
> +		    (first && igc_xdp_is_enabled(adapter) &&
> +		     !igc_test_staterr(rx_desc, IGC_RXD_STAT_EOP)) ||
> +		    unlikely(tsip && size < IGC_TS_HDR_LEN)) {
> +			if (first)
> +				dev_core_stats_rx_dropped_inc(rx_ring->netdev);
> +			xdp_res = IGC_XDP_CONSUMED;
> +			goto xdp_done;
> +		}
> +

[Severity: Medium]
Should the frames dropped here still count toward rx_packets and
rx_bytes?

include/uapi/linux/if_link.h describes rx_packets in rtnl_link_stats64
as including "packets which host had to drop at various stages of
processing (even in the driver)".

Take a hardware-good first descriptor that is dropped only because XDP is
enabled and EOP is not set. It jumps to xdp_done and skips the new
total_bytes/total_packets block, so only rx_dropped and work_done are
incremented. igc_clean_rx_irq_zc() does the same for !eop frames.
igc_update_stats() then exports the ring totals directly as
net_stats->rx_packets and rx_bytes.

Frames that the XDP program drops are still counted in the same function,
and before this patch every descriptor was counted. The commit message
says the exclusion is intentional ("without counting successful RX"), but
that doesn't match the documented semantics.

>  		truesize = igc_get_rx_frame_truesize(rx_ring, size);
>  
>  		pktbuf = page_address(rx_buffer->page) + rx_buffer->page_offset;

[ ... ]

> -		if (igc_fpe_is_pmac_enabled(adapter) &&
> +		if (first && igc_fpe_is_pmac_enabled(adapter) &&
>  		    igc_fpe_handle_mpacket(adapter, rx_desc, size, pktbuf + pkt_offset)) {
>  			/* Advance the ring next-to-clean */
>  			igc_is_non_eop(rx_ring, rx_desc);
>  			cleaned_count++;
> +			work_done++;
>  			continue;
>  		}

[Severity: High]
This is a pre-existing issue, but this block is being modified here. Does
this early exit leak the RX page and its DMA mapping?

igc_get_rx_buffer() always decrements rx_buffer->pagecnt_bias. This path
advances next_to_clean and continues, but it never restores the bias and
never calls igc_put_rx_buffer(). That function is the only place that
recycles or unmaps the page and clears rx_buffer->page.

The slot still holds the page after next_to_clean has moved past it. If
igc_reuse_rx_page() later recycles a buffer into that slot, it overwrites
the page without checking:

drivers/net/ethernet/intel/igc/igc_main.c:igc_reuse_rx_page() {
    ...
	new_buff = &rx_ring->rx_buffer_info[nta];
    ...
	new_buff->page		= old_buff->page;
    ...
}

The old page and its mapping are then lost.

If igc_alloc_rx_buffers() reaches the slot first, igc_alloc_mapped_page()
reuses the page because bi->page is non-NULL, but the bias is one too
low. igc_can_reuse_rx_page() would then always see
(rx_buffer_pgcnt - pagecnt_bias) > 1, so the page is never freed.

igc_fpe_handle_mpacket() returns true for any SMD-V or SMD-R frame. With
pMAC enabled, the link partner can trigger this with every such frame it
sends.

The new drop path in this patch already releases the buffer correctly:
pagecnt_bias++ in the IGC_XDP_CONSUMED case, then igc_put_rx_buffer(),
cleaned_count++ and igc_is_non_eop(). Could the mPacket case release the
buffer the same way?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261025065154.2037149-1-p%401g4.org
Technical Details
Message-ID: <179300059875.3134.14278423796840357371@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351732-linux-kernel-netdev=dewy.ru
References: <20261025065154.2037149-1-p@1g4.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351732-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] igc: track rx frame boundaries independent of skbs
Date: Mon, 26 Oct 2026 07:43:18 +0000
Organization: Usenet Network
Message-ID: <179300059875.3134.14278423796840357371@kernel.org>
References: <20261025065154.2037149-1-p@1g4.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1253306"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:5u5krQ1MkhWH09rj22rR1gp+whI= sha256:TQ/ws6QIQjQ9ia1d+399QiaKnPmtzwaTKWLOb6c4YCw=
	sha1:bsXzDC9KSeVj53KPNDyoQAjylZA= sha256:dAjj38Q3cg4R1JzckCgKg4VfthQJyyybkRGmfRBhOA0=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 5484A125B7B; Mon, 26 Oct 2026 10:44:09 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.739
X-Spam-Status: No, score=-3.739 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id VI9-uJKYj-0z;
	Mon, 26 Oct 2026 10:44:01 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-351732-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id E6606125B8C; Mon, 26 Oct 2026 10:43:52 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 94D182908F; Mon, 26 Oct 2026 07:43:28 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793000606;
	b=KKvRK+tjfRjy+oLKPVa0/d9Zbsh9paNCloM8n0q2Zr9IrSGQbfGT7grNHb0LaMNHbd6/
	 1J3rJqawfgJtDU1kz10lBvXgRPAIGYliniwYFNwzkdM/6biOf/xgVaXDAARWMsf3y+IEY
	 HHzEAyH1ykupy/zNtEtva9uIry40VFm8xizvJ624TQRSuBL9r+3WcSe9x1e0cPmyVAKUx
	 joMABDsttxWRc6ZFD8VthzWeTWkL9fF3XWaGk9PR4RKg91QAbuUTZW2WlrF//XnLOdGcs
	 Cf1mh3ODZKO1Pyw79UNO833zNTzPrcdOpHrHUm63bvkHN6r7QRBVFen8z1u+ujL9viQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793000606;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=hOfnCH+7CYoZiGAiRuh8IJFPtlhrgdv3kKtPaMkLAdQ=;
	b=jec1oOQujqX9l3MuOVYbKvnf40btMEuUxktlIAl8hUDwfMygB7eJTV5aroF3OpRKB+nj
	 ep8a0opxQFXM2z6Rzz9TF5UfONoX5VkCrfCwSHMdyukbQl6rfH9oDLqGu4G+u3CHcALeB
	 ru2Xlm0o1CHBkgdtAWo8w2C4yCp+Jc7QSKWIHBqAGt7nqJw4bUFDn3WSmmdbYlRloS11A
	 jtciBg8r6yE5Y9MRoEUZH+Gcz+CMOTmqS72Mh+munczeMOg3sLUkVv2Dep5NPhJbD8GNj
	 FskFL3wzkmVXSwgeQW4J8T4EIiHu2wdS44ZaWY9EEbz/Rx/GFp1A/atLmGHTOED9e+w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JAdFX2VW;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 89532606A327;
	Mon, 26 Oct 2026 07:43:26 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JAdFX2VW
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793000600;
	b=zqEcJqePClfysMwSikscP0v085HvVwe4GgnCVHhimPcbEpA9R7HOPYwvSZeEQBLoPFCO
	 qCjaDjqZKFqs3CyF40tZGAoNLLLS2UhAdpKPmorh3p7q/kfHbGB7+jGngNAyOGLtoK2q/
	 fF//8LPlUNj1WuOq3ozfTKkvMB9azMSsdmKYpik4Cxma5hLJicuDWtEnAKd5W6PWmWR89
	 c5Vl03XDqz1ctIQvwtE4vLM14Y2L2fdR+8vS0hNOoB9UeuyvotXKpSJuEubiv/vymJCO7
	 xO4J8Z7Towzwa9FwGqI4DKPRMFTD9JoDwCnqSLHGt8rkas1IARd8l1W3Q3Q37/SArHg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793000600;
	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=hOfnCH+7CYoZiGAiRuh8IJFPtlhrgdv3kKtPaMkLAdQ=;
	b=veRkLxMgorbbiJkej2ya6i9WgCdcu2o/2ekgsZJH1gcPSTSQyaPKSCcQrR1DL8IHjcEw
	 AIUPlQOuQ1KJaEZ32mK5Spiud/ItMzdz/WpKRSExcMKfV6hk4Jze2azStjiWCNhyTC0R6
	 H1WXBxf579nA6IqrjDR6YGyCEBH3es1U7pmOwagrWcG2XfFo2jrMhQ8x+JTcyqNq+dk03
	 SWdLlEBbwAIveCPYg4L5ozaMgbapVz3XXGrw0yxuVGwjHX5FY7UgAX13kbIhyLHKSCxRf
	 JC7ssKT9O4M3PEE6tukaadCNa9XqJ5yM1t+Fs+TZtJ/KNuDA92cj6N1MRFuUe0FbC0A==
X-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=JAdFX2VW;
	arc=none smtp.remote-ip=100.103.45.18
X-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 60313606A31A;
	Mon, 26 Oct 2026 07:43:20 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 368C91F01825;
	Mon, 26 Oct 2026 07:43:19 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793000600;
	bh=hOfnCH+7CYoZiGAiRuh8IJFPtlhrgdv3kKtPaMkLAdQ=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=JAdFX2VW5261ezgvvKOnoCW5hSsSCAgV1wUzoQ5lBbc4Pgk7RjwpKp/BBsBXrZuQV
	 L90ZaneqOgiEIVT/LV7VqP0Hmn6PKWgzUFnPfxW0Bf7IVTYwcF8xxOihihy6KKEGhW
	 J1NVs+Yq7CTZBxKJy8qaxvOiUGTGJs1qZwiQWgPdPfS0roekjD4eDLnDvLQcnTJJdg
	 DYZHAudsDg2pEwHDYZR6bQqruYKVi100FFgYGTraG6ir9d4F1skj6A1Haayc5H0ii2
	 WKFb2NzBUAoWD8hhMA2R1nJDoS5L82xQuJ85rjDSuRZOdigcJ5biYWDBiDYN9XHpYg
	 6Y+Mf1e1TkhKA==
X-Cc: 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, ast@kernel.org, daniel@iogearbox.net,
 hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me,
 maciej.fijalkowski@intel.com, vedang.patel@intel.com, jithu.joseph@intel.com,
 andre.guedes@intel.com, intel-wired-lan@lists.osuosl.org,
 netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org
X-In-Reply-To: <20261025065154.2037149-1-p@1g4.org>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list