🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #1169

[PATCH net] net: bcmgenet: unshare the skb before writing the control block

#1169
From: Nicolai Buchwitz
Date: Fri, 09 Oct 2026 10:10
70 lines
8253 bytes
bcmgenet stores first_cb, last_cb and bytes_sent in the skb control
block and reads them back on completion to free the skb and credit BQL.
ether_setup() leaves IFF_TX_SKB_SHARING set, so the stack can resubmit
a shared skb that is still in the ring. The next transmit overwrites
last_cb, so the earlier slots complete without crediting their bytes
and BQL stalls the queue until the watchdog resets it.

Unshare the skb before writing the control block.

Reproduce with pktgen in clone_skb mode, which hands the driver the same
skb while earlier copies are still in the ring:

  modprobe pktgen
  pg=/proc/net/pktgen
  echo "add_device eth0" > $pg/kpktgend_0
  echo "dst_mac AA:BB:CC:DD:EE:FF" > $pg/eth0
  echo "dst 192.0.2.1" > $pg/eth0
  echo "clone_skb 8" > $pg/eth0
  echo "count 0" > $pg/eth0
  echo start > $pg/pgctrl &
  sleep 5
  echo stop > $pg/pgctrl
  wait
  cat /sys/class/net/eth0/queues/tx-0/byte_queue_limits/inflight

inflight stays nonzero on the now idle queue. clone_skb 0 leaves it at
zero.

Fixes: f48bed16a756 ("net: bcmgenet: Free skb after last Tx frag")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
Another finding while testing the genet MTU series. Similar shared-skb
bug as the macb fixes already merged in net [1], here in bcmgenet's Tx
control block rather than the software FCS path.

[1] https://lore.kernel.org/netdev/20261006-nb-macb-shared-skb-net-v1-0-a80641479041@tipi-net.de/
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index e8908916558b..f4cfbff49a1b 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2153,6 +2153,16 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev)
 		goto out;
 	}
 
+	/* We store Tx state in the control block, so the skb must not be
+	 * shared, but ether_setup() leaves IFF_TX_SKB_SHARING set.
+	 */
+	skb = skb_share_check(skb, GFP_ATOMIC);
+	if (!skb) {
+		BCMGENET_STATS64_INC((&ring->stats64), dropped);
+		ret = NETDEV_TX_OK;
+		goto out;
+	}
+
 	/* Retain how many bytes will be sent on the wire, without TSB inserted
 	 * by transmit checksum offload
 	 */

---
base-commit: af32da41b0327b9c6a37856ba82b6760d6c8d10e
change-id: 20261009-nb-genet-shared-skb-net-5747ee5df864

Best regards,
--  
Nicolai Buchwitz <nb@tipi-net.de>
Technical Details
Message-ID: <20261009-nb-genet-shared-skb-net-v1-1-c6d0a841977d@tipi-net.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-343571-linux-kernel-netdev=dewy.ru

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-343571-linux-kernel-netdev=dewy.ru
From: nb@tipi-net.de (Nicolai Buchwitz)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] net: bcmgenet: unshare the skb before writing the
 control block
Date: Fri, 09 Oct 2026 12:10:41 +0200
Organization: Usenet Network
Message-ID: <20261009-nb-genet-shared-skb-net-v1-1-c6d0a841977d@tipi-net.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="1081158"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:cXf+Sn0h4onUYWWTDX9lnfBpSJI= sha256:1lPi24NNq6jiwXrCX3O16OlQH5La6zLIvj8NcnBCIPk=
	sha1:UC6/b/z3xGtJ9xtPxKPfMvuRm0o= sha256:tIZMc/WuX2ZQ4Iqd3IfUkeG5SMvxZ6WC1CY3/A68yGM=
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 E50A010F64A; Fri,  9 Oct 2026 13:17:45 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -0.751
X-Spam-Status: No, score=-0.751 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, 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=tipi-net.de
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 qMFsuSRdPuif;
	Fri,  9 Oct 2026 13:17:42 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-343571-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=tipi-net.de
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 7904D10F639; Fri,  9 Oct 2026 13:17:37 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id E75E53EBA8; Fri,  9 Oct 2026 10:11:08 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E7744963BA;
	Fri,  9 Oct 2026 10:11:08 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.b="b9tCNn+5"
X-Received: from mail.tipi-net.de (mail.tipi-net.de [194.13.80.246])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E30243E9CB;
	Fri,  9 Oct 2026 10:11:02 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.13.80.246
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791540668; cv=none; b=bRMSZnEhMSgfdJyxJbGMiFe6hZRnCufMzipLBO7tP3LSLlvvU2E2a+UhmKDxjQ2SvkAOP4rxE493/QLSz//RxCi2UPzqo8cWHoh7iw2shbWSuUO9pdcdOTO/yP6cjDEUBG3mGsd/WGBjP8XP/bM5LXnCJRcBbFpyf5tamWLB704=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791540668; c=relaxed/simple;
	bh=fha1a3arIoJLlTVM53k7P7B7fPGKH9vmXcXb315lgc4=;
	h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=HoGFU9N9e78U8BFXz6v0q9cq7/UbAwlgzEP/1LNrlbotGGusohWJLLlD/1fl2IvFc40YvyLBn1w4xDw2PPqwfF2g1NaRanfLKgkjohSfWgzfp+6YVIg27b01C5A3nrC8ya4yhcYyKpoG1nMYxvNOyzPRXQnNEXqRa8MRPhVHDJw=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de; spf=pass smtp.mailfrom=tipi-net.de; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.b=b9tCNn+5; arc=none smtp.client-ip=194.13.80.246
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tipi-net.de
X-Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 5FCE3A1546;
	Fri,  9 Oct 2026 12:10:57 +0200 (CEST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tipi-net.de; s=dkim;
	t=1791540660; h=from:subject:date:message-id:to:cc:mime-version:content-type:
	 content-transfer-encoding; bh=O/E93M9qF++wqqPi27386nQo3pvtjSqURQxn24uotfg=;
	b=b9tCNn+5/p6SoTKL7k+Jr8zBPjvw4+29TqG5U47b5HYtJ81d8gVh6jEszVbzHxWZ0Q7Lgx
	h3dP3Hr5m3U9fLAqKXgTWynYDwgxywJnY22sylGREzcwRYedpnqlroQQS8tAcT10C15esO
	xdo/tad5cGgEi1vtec6ekZzWrt5YD7qIWs8yKlNIN17ORw1OoWMOL+Yp93tz2mgxUNp4+p
	Ddfec0h6Rz/lDHvi5l470x1wd7TyZsIj68gWXH3abBQhVqX/qfqdXplL9TtkUTSdxLMbCE
	6AYSJvusNwYSuNqGcmULNhANH4UA7vq7bZo3vRziZEZvOqpRK99xCqQj1FBTZw==
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-B4-Tracking: v=1; b=H4sIAAAAAAAC/yWMyw6CQBAEf4X02UkWwkP9FeOBZRsYTVazg8aE8
 O8ueqxOV60wJqXhXKxIfKvpI2YoDwWGuY8TRUNmVK5qS+dOEr1MjFzE5j4xiN297Nh0dUc2YTy
 2NbL9TBz18ytfkA+4/kd7+RuHZW9i275PZLT7gAAAAA==
X-Change-ID: 20261009-nb-genet-shared-skb-net-5747ee5df864
X-Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, 
 Nicolai Buchwitz <nb@tipi-net.de>
X-Mailer: b4 0.16.0
X-Last-TLS-Session-Version: TLSv1.3