Article View: linux.kernel.netdev
Article #23971[PATCH net] net: stmmac: Drop TX buffers too long for normal descriptors
From: Arun Iyengar via B4 Relay
Date: Sat, 28 Nov 2026 19:00
Date: Sat, 28 Nov 2026 19:00
83 lines
13644 bytes
13644 bytes
From: Arun Iyengar <aiyengar1990@gmail.com>
Sashiko found in [1] that stmmac_xmit() does not check buffer sizes for
normal descriptors, whose size field has 11 bits. As Chen-Yu Tsai noted
in [2], only enhanced descriptors take the jumbo path that splits
buffers, since commit 29896a674c8e ("stmmac: fix chained mode"). A
longer buffer gets its size cut in chain mode, and in ring mode its
rest goes to buffer 2 at DES3, which is 0.
Such skbs come from MTUs above one buffer, and from act_mirred and BPF
redirect, which do not check the MTU. Drop them and count them in
tx_dropped.
Link: https://lore.kernel.org/r/179542841718.3135.3290374626862889297@kernel.org [1]
Link: https://lore.kernel.org/r/CAGb2v66oxp7G92psuF-pQsha5doh47j2gSMiTY7PAB2dYfozUw@mail.gmail.com [2]
Fixes: 48febf7e6476 ("stmmac: allow mtu bigger than 1500 in case of normal desc (V4)")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
Tested on an H616 (chain mode) with skbs of 1600 to 9000 bytes from
tc mirred at MTU 1500. Without this patch, TX stops at a 2048-byte
linear skb until the TX watchdog resets it. With it, every skb with a
buffer of 2048 bytes or more is dropped and counted, and TX stays up.
Ring mode is untested. AF_XDP zero-copy TX has the same gap and is not
covered.
Developed with Claude (Anthropic), which wrote the code and the commit
message. I reviewed every change.
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 25 +++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a685ce4638f6..f21f7fc1beb7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2033,6 +2033,25 @@ static void stmmac_set_tx_dma_last_segment(struct stmmac_tx_queue *tx_q,
tx_q->tx_skbuff_dma[entry].last_segment = true;
}
+/* Normal descriptors have an 11-bit buffer size */
+static bool stmmac_ndesc_tx_too_long(struct stmmac_priv *priv,
+ struct sk_buff *skb)
+{
+ unsigned int i;
+
+ if (priv->hw->desc != &ndesc_ops)
+ return false;
+
+ if (skb_headlen(skb) >= BUF_SIZE_2KiB)
+ return true;
+
+ for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
+ if (skb_frag_size(&skb_shinfo(skb)->frags[i]) >= BUF_SIZE_2KiB)
+ return true;
+
+ return false;
+}
+
/**
* __init_dma_tx_desc_rings - init the TX descriptor ring (per queue)
* @priv: driver private structure
@@ -4889,6 +4908,12 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
}
}
+ if (unlikely(stmmac_ndesc_tx_too_long(priv, skb))) {
+ dev_kfree_skb(skb);
+ priv->xstats.tx_dropped++;
+ return NETDEV_TX_OK;
+ }
+
if (unlikely(stmmac_tx_avail(priv, queue) < nfrags + 1)) {
if (!netif_tx_queue_stopped(netdev_get_tx_queue(dev, queue))) {
netif_tx_stop_queue(netdev_get_tx_queue(priv->dev,
---
base-commit: 28a371228d4eb4857cc31eeb1a0d7d01e9c3ea2f
change-id: 20261127-stmmac-ndesc-tx-len-ef99cde11a8b
Best regards,
--
Arun Iyengar <aiyengar1990@gmail.com>
Technical Details
Message-ID:
<20261128-stmmac-ndesc-tx-len-v1-1-69f737224dc0@gmail.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373263-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373263-linux-kernel-netdev=dewy.ru From: devnull+aiyengar1990.gmail.com@kernel.org (Arun Iyengar via B4 Relay) Newsgroups: linux.kernel.netdev Subject: [PATCH net] net: stmmac: Drop TX buffers too long for normal descriptors Date: Sat, 28 Nov 2026 19:00:38 +0000 Organization: Usenet Network Message-ID: <20261128-stmmac-ndesc-tx-len-v1-1-69f737224dc0@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="1010519"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:GJPRuZD4IxCwQqlIZiOBEvwVylE= sha256:3WIpIdlo+yE83GALKZcgOUoeEKwA/rsAJ3ydxaQa9YI= sha1:HA5U5nHUwiHw39cL1b0jITdIDU0= sha256:d5QTykf2MKc7nVqo3MRcm7zOoAWRiijvqZi/sAdwOxk= 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 CA97A125F8C; Sat, 28 Nov 2026 22:01:01 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.151 X-Spam-Status: No, score=-3.151 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_REPLYTO_END_DIGIT=0.25, 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 FN11lOPSGUhc; Sat, 28 Nov 2026 22:00:53 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373263-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 499E9125F86; Sat, 28 Nov 2026 22:00:44 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id E1CAD27C9A; Sat, 28 Nov 2026 19:00:40 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795892440; b=JIoNRUtWtON4Lmj6dItu6TA9M4CXcF24wenU1gmY+ZewPkQtv9Jhtgm6zxeJEAGYEiYd ZSG2J2Vo5PS3alGq9eIbFud30C9YBI4dQph3dL7tb3R/GCIomZzavZK5EgJ/5Aor6cQsb /qJ0q4SO4tnlPRol1rD4smfJ9N+ffi7bC2DGA36c1yjvVecxzXOcdvpZ1AxskeEitBU/F zcniL5loVqYurt+afKN4kqm6/5QOI3buRYhnwSqE+a/eP3DGX0nLBbH5mKV8Eez5E1fyK GOWbFkWTYyLASPZS5dzZ+y3yDcCH2GqrD2sSrmC3t1Za8ZpEB63w6txWiwsAMFu98ZA== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795892440; h=X-Original-To:Received:Received:DKIM-Signature:Received:From:Date: Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=b6pj/aH4gWBKyZr73GguJXovw9+TYJt/x+CnbRp9od8=; b=uTgae1wAM0CkF1t547yi+w/hQtrvffY2hQI59styiMEmtlGUfioiME8PyQDdEEw5RAO2 bXFAIyC0oObuklSCNlzjhoX2SnFPX7vlNcJZl8PghG29d5DaVwaGcMjlGI1Q83oUptpw6 oQXEJHxIR3s+R9VKyza1v+x/5OhN07InAun4gr+9CB8ozlBJVPSWGdyWj2NZ7m8OI4nJK emDQBwMcdH4FxQUy3U3svY5zrTDBg78q6UAXNoEmctqBzkR/SKKG5L/vUe3UQVe/GYeyI dvoDDnGgevAAwnrkv/xxfEDdIVX1YTWTEYEv7DdKiiNO1fC7l0fjfO8DRz9jiv5yHmQ== X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DN2PjBvR; 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 AF9F6606A321; Sat, 28 Nov 2026 19:00:40 +0000 (UTC) X-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=DN2PjBvR X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795892439; b=SCypIn1kKsUJ3g+llu+eTkdmsViFaMMJphOmcpRiEgwmdzIzNu6VDcMK9R0GA0tkfmqf SkwmvzOBZMpMae7W7Vum74Kh8WUFBWrHKyYhIKiR/2CqW1ShlNpndNvWJs7+93XcQ3GQx QDmXPgQAJxIdsaqOnoz5G9nb8IaUVpwt/GflNMjKehksh86vocuaET4DGKkz5J3+vCpaU i2xDSq++Z1Aim78YcfPIM2BJFTdYoGC4BiWCUJoigHGIKN5yAVW7BDP/rEvxKUxwRjqxd ch0NanZnDR1vSW2LRjTpZD+VLdG2uVi+EYwQZ6drSZWBK0fmgiF0c1xJEZTAhkZGNEA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795892439; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=b6pj/aH4gWBKyZr73GguJXovw9+TYJt/x+CnbRp9od8=; b=Sa3ou8ypOcu8QpGYQ/7CQTTIIUkKQ+WqaRvDFnutjlVWE5BDA+Vkl8ufZiVV21+K9Nid iPxjiquIGWkoSHw7urOwGNVMePHqg8+ZcxdH8yUJWUMP3PD2MASGIpYeY1mgUdN7o8can ceg/PujOXWGE1YHKNI+fsaZNeo3laP3YFojttr3rhEN0/z95uophtOTh6nPmGMT6h+wVE NJm+EOn1rvVmE95Fhw81gDYI2cw8JbQY9kzaHEDDm++0+v6dJA64zMwfo/j17aN1hIEfw wuIPcBh1wX8Cg86mxA6RcwDiCt3YRvWft/SrT8vY85//7D4onWqK9WPV0sSA+ij9pRQ== 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=DN2PjBvR; arc=pass header.oldest-pass=0 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) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB051606A323 for <netdev@vger.kernel.org>; Sat, 28 Nov 2026 19:00:39 +0000 (UTC) X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1795892439; b=PU5QindKjtz0kUjCze5aW68ss8MrUALDzAm7uxrwxz7ZNpKGt3oE3FDg2bfscn/+/Q+k izfvzUL72QDNGyhdqKGpFcrYpqUs3YZcKTWGEDTF021sgPHyl4/pzcUCBVSg2eRMNiI8U I5xFSyHfzkz/8YRew/+QZjBprMKQiAV9Bl+bMFxUeRkUvW9YowTQgIjrDyGtAVl/ftbpx yV2xqX8YEUDrfxjVFvungf7ESPZwa9UtS+gJL5/kMGZhMwrpZcDxgQ318BXpG9UNtaDgs xb3W8kv5Xwje07zDuVf2AWUz1Bat9HOAUgGyaZI0XapeFhTGSEHwYDkagmOPFTMgA6A== X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1795892439; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=b6pj/aH4gWBKyZr73GguJXovw9+TYJt/x+CnbRp9od8=; b=dNN5Zhm9+26/8CK5kSjeva9xgw4VXXfxoW9gfgyoKfwTihnQP250dmAP6NU8t3CeXUBD 7Ma7kC2A2xczZZj51BJX2x17JwAMUyRNhn4aUl/dCAPPR4/FXVieW4Dds+DRSnp+KxTQ1 wGQrZR3G+qeuvEe3sR2OLN1VMiQ89ZvlUuxr9GBF4GG1wAJbC8huZ7AcaiOAe2nHfaHZ8 Fd0irglqF/hFNfWTRACSQBa0BPzixGDHsdPgH0nZ1vHm4MMO4lJwPaaWvVIGKhRsd6+M0 ChUFPmQxzaXOLVjXRVaTTdexpZLlG/bCymury6dztDz3Ia7siEKoDxAnazXWLiGgJmw== X-ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (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.kernel.org (Postfix) with ESMTPS id D81F51F00899; Sat, 28 Nov 2026 19:00:38 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795892439; bh=b6pj/aH4gWBKyZr73GguJXovw9+TYJt/x+CnbRp9od8=; h=From:Date:Subject:To:Cc:Reply-To; b=DN2PjBvRJVF5YwwyC0RxuKxsssi1RrX+SYOzvuvB7PUBoBaWsa5piVHdM9Vu7MH4D h7t9+mTOyg4RFBKn9JlTCad1EKgZGvj/fzXXJBkAOYu77UP/YwdlVLdqQTq7AStNdu n3rtPx/L9BV1NVe1EK/2pTuYqJzvnLBENLtKQ15mE3GK3uOH+34e7mGGldiWUIZTE+ 2o+ADBBr1s7vkNoG3jbQXGVFbCE/fexPykW/0qQU0ISlK23LiPp5chVvJheDhRZ1bJ dDKAo9ujfEXpV24tT/SDXo5JwQhHOuyy8l/m5pvJWvs/ua1fcb7IISq0jwTnZpiE6R e5qjvcEFvnGJA== X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 386C04E1E1; Sat, 28 Nov 2026 19:00:38 +0000 (UTC) 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 X-B4-Tracking: v=1; b=H4sIAAAAAAAC/yWMwQrCMBAFf6Xs2QU3B7X+inhIN6+6YqNkoxRK/ 92oxxmYWchRDE7HbqGCt7k9cgPZdKTXmC9gS40pbMNOJOzZ6zRF5ZzgynXmOzJj7HtNEImHgVr 5LBht/l1PlFHp/Jf+Gm7Q+v3Run4AgfLLEnwAAAA= X-Change-ID: 20261127-stmmac-ndesc-tx-len-ef99cde11a8b X-Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Arun Iyengar <aiyengar1990@gmail.com> X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795892437; l=3104; i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id; bh=UKsD2T2AGKzpC1WaupMUb300yebHh9UxQbyihv5XzcA=; b=6CotknO2Uph/1v38egcb3CMfNMft+oF9JiuwTddyu+L6OEZsBanvDXRX7duiPGFb92TCJ68BP C+T6P+VYkEFDIk2MHgC2bC0qPoPiHpwECs94HSYuEysoB5jkBbiOu7E X-Developer-Key: i=aiyengar1990@gmail.com; a=ed25519; pk=zXpRgUTrhaFe6jLyPqbBy3ccfkj04w0g2690Wv3mg+0= X-Endpoint-Received: by B4 Relay for aiyengar1990@gmail.com/20261110 with auth_id=1480 X-Original-From: Arun Iyengar <aiyengar1990@gmail.com> X-Reply-To: aiyengar1990@gmail.com