Subject: Re: [PATCH net] net: atlantic: fix fragment overflow handling in RX path

From: Jakub Kicinski <[email-masked]>
Date: Tue, 18 Nov 2025 12:24:30 -0800

On Tue, 18 Nov 2025 15:04:02 +0800 [email-masked] wrote:
> From: Jiefeng Zhang <[email-masked]>
> 
> The atlantic driver can receive packets with more than MAX_SKB_FRAGS (17)
> fragments when handling large multi-descriptor packets. This causes an
> out-of-bounds write in skb_add_rx_frag_netmem() leading to kernel panic.
> 
> The issue occurs because the driver doesn't check the total number of
> fragments before calling skb_add_rx_frag(). When a packet requires more
> than MAX_SKB_FRAGS fragments, the fragment index exceeds the array bounds.
> 
> Add a check in __aq_ring_rx_clean() to ensure the total number of fragments
> (including the initial header fragment and subsequent descriptor fragments)
> does not exceed MAX_SKB_FRAGS. If it does, drop the packet gracefully
> and increment the error counter.

First off, some basic Linux mailing list savoir vivre:
 - please don't top post
 - please don't resubmit your code within 24h of previous posting
 - please wait for a discussion to close before you send another version

Quoting your response:

https://lore.kernel.org/all/[email-masked]/

> I have used git send-email to send my code.
> 
> As for the patch --The aquantia/atlantic driver supports a maximum of
> AQ_CFG_SKB_FRAGS_MAX (32U) fragments, while the kernel limits the
> maximum number of fragments to MAX_SKB_FRAGS (17).

Frag count limits in drivers are usually for Tx not Rx.
Again, why do you think this driver can generate more frags than 17?
-- 
pw-bot: cr