From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Maxime Chevallier <maxime.chevallier@bootlin.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH net-next 4/9] net: stmmac: descs: fix buffer 1 off-by-one error
Date: Thu, 8 Jan 2026 11:41:15 +0000 [thread overview]
Message-ID: <aV-X20nSS-JahPr6@shell.armlinux.org.uk> (raw)
In-Reply-To: <4bf4ec53-c972-4009-b827-5083e080f32f@bootlin.com>
On Wed, Jan 07, 2026 at 10:28:30AM +0100, Maxime Chevallier wrote:
> Hi Russell,
>
> On 06/01/2026 21:31, Russell King (Oracle) wrote:
> > norm_set_tx_desc_len_on_ring() incorrectly tests the buffer length,
> > leading to a length of 2048 being squeezed into a bitfield covering
> > bits 10:0 - which results in the buffer 1 size being zero.
> >
> > If this field is zero, buffer 1 is ignored, and thus is equivalent
> > to transmitting a zero length buffer.
> >
> > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
>
> Should it be a fix ? I've tried to trigger the bug without success, this
> seems to be fairly specific so I'm OK with it going to net-next.
Note that you need hardware that doesn't use enhanced descriptors -
which descriptors get used are dependent on the hardware rather than a
runtime option.
Note that we have this silly code, which I've brought up in the past:
if (priv->plat->core_type == DWMAC_CORE_XGMAC)
ndev->max_mtu = XGMAC_JUMBO_LEN;
else if (priv->plat->enh_desc || priv->synopsys_id >= DWMAC_CORE_4_00)
ndev->max_mtu = JUMBO_LEN;
else
ndev->max_mtu = SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN);
where the "silly" part is that last line - SKB_MAX_HEAD() is dependent
on PAGE_SIZE. So, if you build your kernel for e.g. 64K page sizes, but
stmmac doesn't have enhanced descriptor support, ->max_mtu ends up being
close to 64K, and you can configure the netdev's MTU to be that large.
Even with a 4KiB page size, max_mtu will certainly be greater than
2KiB.
That means stmmac_xmit() can be called with packets >= 2KiB in length.
As stmmac_xmit() has this:
/* To program the descriptors according to the size of the frame */
if (enh_desc)
is_jumbo = stmmac_is_jumbo_frm(priv, skb->len, enh_desc);
the code will not treat them as jumbo frames, and thus
stmmac_jumbo_frm() will not be called. This means we'll call
stmmac_set_desc_addr() and stmmac_prepare_tx_desc() only for each
fragment of the skb, which only supports buffer 1 in the descriptor.
There is the possibility for a descriptor to supply the next chunk of
the packet in buffer 2 (with its separate length field of the same
bit size) but the driver doesn't do that in this path.
So, even if we did get a fragment >= 2KiB, the code would only be able
to send up to the maximum size that can fit in the descriptor.
This patch fixes the logical problem in the code, but doesn't fix this
larger issue.
The real problem is the setting of max_mtu - it should _not_ be
dependent on only the kernel's page size, but should be limited by the
capabilities of the hardware and software. That was what I was trying
to raise when I brought up the issue of max_mtu, but no one responded.
So, I decided to only correct the logical problem instead as it seems
no one cares about the bigger issue.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2026-01-08 11:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-06 20:30 [PATCH 0/9] net: stmmac: cleanups and low priority fixes Russell King (Oracle)
2026-01-06 20:31 ` [PATCH net-next 1/9] net: stmmac: dwmac4: remove duplicated definitions Russell King (Oracle)
2026-01-07 8:24 ` Maxime Chevallier
2026-01-06 20:31 ` [PATCH net-next 2/9] net: stmmac: dwmac4: fix RX FIFO fill statistics Russell King (Oracle)
2026-01-07 8:38 ` Maxime Chevallier
2026-01-06 20:31 ` [PATCH net-next 3/9] net: stmmac: dwmac4: fix PTP message type field extraction Russell King (Oracle)
2026-01-07 8:41 ` Maxime Chevallier
2026-01-06 20:31 ` [PATCH net-next 4/9] net: stmmac: descs: fix buffer 1 off-by-one error Russell King (Oracle)
2026-01-07 9:28 ` Maxime Chevallier
2026-01-08 11:41 ` Russell King (Oracle) [this message]
2026-01-08 12:19 ` Russell King (Oracle)
2026-01-06 20:31 ` [PATCH net-next 5/9] net: stmmac: descs: use u32 for descriptors Russell King (Oracle)
2026-01-07 9:58 ` Maxime Chevallier
2026-01-06 20:31 ` [PATCH net-next 6/9] net: stmmac: descs: remove many xxx_SHIFT definitions Russell King (Oracle)
2026-01-06 20:31 ` [PATCH net-next 7/9] net: stmmac: cores: " Russell King (Oracle)
2026-01-06 20:31 ` [PATCH net-next 8/9] net: stmmac: arrange register fields after register offsets Russell King (Oracle)
2026-01-06 20:31 ` [PATCH net-next 9/9] net: stmmac: remove unused definitions Russell King (Oracle)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aV-X20nSS-JahPr6@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox