Netdev List
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev-bot+sashiko@kernel.org
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, hkallweit1@gmail.com, linux@armlinux.org.uk,
	shaojijie@huawei.com, horms@kernel.org, runyu.xiao@seu.edu.cn,
	mmyangfl@gmail.com, hvr@gnu.org, jeff@garzik.org,
	danny.kukawka@bisect.de, mugunthanvnm@ti.com,
	sebastian.hesselbarth@gmail.com, linux-kernel@vger.kernel.org,
	manuel.lauss@gmail.com
Subject: Re: [PATCH net v2 12/12] net: au1000: reject frames larger than the TX bounce buffer
Date: Tue, 17 Nov 2026 11:19:58 -0800	[thread overview]
Message-ID: <78fc6217-463d-4ad7-9bc5-d737a435ec3e@gmail.com> (raw)
In-Reply-To: <179483705182.3136.18065066878486336390@kernel.org>

On 11/16/26 05:50, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found more severe
> issue(s) in other patches of this series. This mail is only an FYI, in case
> you want to address the nit picks below when you respin.
> 
> Low priority / nit picks for your consideration:
> 
> - [Low] The commit message understates how the overflow can be reached.
> 
> Pre-existing issues:
> - [High] Several other drivers in drivers/net/ethernet/amd/ have the same
>    unchecked copy of skb->len bytes into a fixed-size TX buffer.
> 
> --
> 
> net: au1000: reject frames larger than the TX bounce buffer
> 
> This patch adds a length check to au1000_tx(). Frames larger than
> MAX_BUF_SIZE are now dropped and counted in tx_dropped instead of being
> copied past the end of the TX bounce buffer.
> 
>> au1000_tx() copies skb->len bytes into a MAX_BUF_SIZE coherent buffer
>> without checking the length. Oversized non-GSO packets can reach this
>> path through AF_PACKET with PACKET_VNET_HDR and PACKET_TX_RING, whose
>> MTU checks are skipped when a virtio header is present.
> 
> [Severity: Low]
> Is this description narrower than the real exposure? It reads as though
> PACKET_TX_RING is required. The plain sendmsg path through packet_snd()
> seems to get to the same place:
> 
> net/packet/af_packet.c:packet_snd() {
>      ...
> 	if (!vnet_hdr.gso_type &&
> 	    (len > dev->mtu + reserve + VLAN_HLEN + extra_len))
> 		goto out_unlock;
>      ...
> }
> 
> After that, __virtio_net_hdr_to_skb() only marks the skb as GSO when the
> payload is larger than gso_size:
> 
> 	/* Too small packets are not really GSO ones. */
> 	if (skb->len - nh_off > gso_size) {
> 
> Take a 4000-byte frame sent with gso_type=TCPV4 and gso_size=65000. It
> would skip the MTU check and reach au1000_tx() as an ordinary non-GSO skb.
> 
> Real GSO skbs also get through, because gso_size is never checked against
> dev->mtu. au1000 has no TSO, so validate_xmit_skb() segments them in
> software into frames that can be larger than 2048 bytes.
> 
> The new check in au1000_tx() catches all of these paths, so the code
> looks right. Could the commit message also mention the packet_snd() and
> GSO routes?
> 
>> diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
>> index d60430a3795ed..d8855ccf87aa1 100644
>> --- a/drivers/net/ethernet/amd/au1000_eth.c
>> +++ b/drivers/net/ethernet/amd/au1000_eth.c
>> @@ -1008,6 +1008,12 @@ static netdev_tx_t au1000_tx(struct sk_buff *skb, struct net_device *dev)
>>   	int i;
>>   	unsigned long flags;
>>   
>> +	if (unlikely(skb->len > MAX_BUF_SIZE)) {
>> +		dev->stats.tx_dropped++;
>> +		dev_kfree_skb_any(skb);
>> +		return NETDEV_TX_OK;
>> +	}
> 
> [Severity: High]
> This is a pre-existing issue that this patch did not introduce. Do other
> drivers in drivers/net/ethernet/amd/ need the same check?
> 
> Several lance_start_xmit() implementations copy skb->len bytes into
> fixed-size TX slots with no upper bound. Their slots are smaller than
> au1000's 2048-byte MAX_BUF_SIZE, so a frame one byte over the limit
> already overruns the slot:
> 
> 7990.c:lance_start_xmit()
>      skb_copy_from_linear_data(skb, (void *)&ib->tx_buf[entry][0], skblen);
>      (skblen = skb->len, tx_buf slots are 1544 bytes)
> 
> a2065.c:lance_start_xmit()
>      skb_copy_from_linear_data(skb, (void *)&ib->tx_buf[entry][0], skblen);
>      (skblen = max(skb->len, ETH_ZLEN), tx_buf slots are 1544 bytes)
> 
> sunlance.c:lance_start_xmit()
>      PIO path: lance_piocopy_from_skb()
>      DMA path: skb_copy_from_linear_data(skb, &ib->tx_buf [entry][0], skblen);
>      (TX_BUFF_SIZE is 1544)
> 
> sun3lance.c:lance_start_xmit()
>      skb_copy_from_linear_data(skb, PKTBUF_ADDR(head), skb->len);
>      (PKT_BUF_SZ is 1544)
> 
> atarilance.c:lance_start_xmit()
>      lp->memcpy_f( PKTBUF_ADDR(head), (void *)skb->data, skb->len );
>      (PKT_BUF_SZ is 1544)
> 
> declance.c:lance_start_xmit()
>      cp_to_buf(lp->type, lp->tx_buf_ptr_cpu[entry], skb->data, len);
>      (len = skb->len, TX buffers are 1536 bytes)
> 
> Using the AF_PACKET route from the commit message, can an oversized frame
> in these drivers overwrite the next TX slot and then the RX buffers?
> 
> For frames near 64KB, the copy also looks like it would run past the end
> of the lance_init_block or shared memory area.
> 
> Triggering this needs CAP_NET_RAW in the device's netns. The hardware is
> legacy: Amiga, Sun, Atari, DEC and HP300/MVME.
> 

Agreed. I have expanded the commit message to cover both packet_snd() 
and TX_RING, including packets left non-GSO after virtio-header 
conversion and oversized segments produced by software GSO. The existing 
length check covers these cases.

The other AMD drivers require separate validation and fixes; they are 
outside this au1000 series.

pw-bot: cr
-- 
Florian

      reply	other threads:[~2026-11-17 19:20 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  4:52 [PATCH net v2 00/12] net: au1000: Bug fixes Florian Fainelli
2026-11-12  4:52 ` [PATCH net v2 01/12] net: au1000: recycle RX descriptors on allocation failure Florian Fainelli
2026-11-12  4:52 ` [PATCH net v2 02/12] net: au1000: clear all-multicast mode when restoring hash filtering Florian Fainelli
2026-11-12  4:52 ` [PATCH net v2 03/12] net: au1000: disconnect the PHY before freeing the MDIO bus Florian Fainelli
2026-11-12  4:52 ` [PATCH net v2 04/12] net: au1000: report MDIO transaction timeouts Florian Fainelli
2026-11-16 13:50   ` netdev-bot+sashiko
2026-11-17 19:09     ` Florian Fainelli
2026-11-12  4:52 ` [PATCH net v2 05/12] net: au1000: serialize TX completion with packet submission Florian Fainelli
2026-11-12  4:52 ` [PATCH net v2 06/12] net: au1000: assign a valid MAC address without platform data Florian Fainelli
2026-11-16 13:50   ` netdev-bot+sashiko
2026-11-17 19:11     ` Florian Fainelli
2026-11-12  4:52 ` [PATCH net v2 07/12] net: au1000: fix buffer descriptor free list insertion Florian Fainelli
2026-11-16 13:50   ` netdev-bot+sashiko
2026-11-17 19:13     ` Florian Fainelli
2026-11-12  4:52 ` [PATCH net v2 08/12] net: au1000: restore receive filtering before enabling RX Florian Fainelli
2026-11-12  4:52 ` [PATCH net v2 09/12] net: au1000: restore RX buffer addresses when restarting the MAC Florian Fainelli
2026-11-12  4:52 ` [PATCH net v2 10/12] net: phy: smsc: wait for LAN83C183 power-down recovery Florian Fainelli
2026-11-16 13:50   ` netdev-bot+sashiko
2026-11-17 19:15     ` Florian Fainelli
2026-11-12  4:52 ` [PATCH net v2 11/12] net: au1000: keep the MAC stopped until the PHY link is ready Florian Fainelli
2026-11-16 13:50   ` netdev-bot+sashiko
2026-11-17 19:18     ` Florian Fainelli
2026-11-12  4:52 ` [PATCH net v2 12/12] net: au1000: reject frames larger than the TX bounce buffer Florian Fainelli
2026-11-16 13:50   ` netdev-bot+sashiko
2026-11-17 19:19     ` Florian Fainelli [this message]

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=78fc6217-463d-4ad7-9bc5-d737a435ec3e@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=danny.kukawka@bisect.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=hvr@gnu.org \
    --cc=jeff@garzik.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=manuel.lauss@gmail.com \
    --cc=mmyangfl@gmail.com \
    --cc=mugunthanvnm@ti.com \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=runyu.xiao@seu.edu.cn \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=shaojijie@huawei.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