FAILED: patch "[PATCH] net: atl1c: drop oversized RX frames instead of panicking" failed to apply to 5.10-stable tree
Subsystems (3)
Sasha Levin
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x c4ba1716853de5178a9df785844ebb5e397a80e6
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From c4ba1716853de5178a9df785844ebb5e397a80e6 Mon Sep 17 00:00:00 2001
From: Federico Musto <[email protected]>
Date: Tue, 27 Oct 2026 12:51:51 +0100
Subject: [PATCH] net: atl1c: drop oversized RX frames instead of panicking
atl1c sizes its receive buffers from the netdev MTU plus a fixed set of L2 overheads, which comes to 1522 bytes at the default MTU. A link partner that sends a longer frame - in practice a MikroTik CCR2004-1G-2XS-PCIe, whose RouterOS side defaults to l2mtu 1600 while the host stays at MTU 1500
- makes the length reported by the RX return descriptor exceed what the hardware wrote, and skb_put() then either includes bytes that were never received or trips skb_over_panic and takes the host down.
Compare the descriptor length against buffer_info->length, the length the hardware was given, rather than against skb_tailroom(): the skb carries 64 bytes of slack for the DMA erratum, so tailroom is larger than the DMA buffer and a frame in between would pass the check and still be delivered with a tail the device never wrote. The same test rejects frames shorter than ETH_HLEN + ETH_FCS_LEN; before this change a reported length below ETH_FCS_LEN underflowed in skb_put().
The frame is dropped with kfree_skb_reason(SKB_DROP_REASON_PKT_TOO_BIG) so drop_monitor and the kfree_skb tracepoint see it, and counted through dev_core_stats_rx_dropped_inc(), which survives atl1c_get_stats() overwriting the hardware counters on every read. It also counts as work:atl1c_clean_rfd() has already recycled the RFD, and the refill at the end of the poll only runs when work_done is non-zero, so sustained oversized traffic would otherwise drain the ring and stop RX.
Tested on a MikroTik CCR2004-1G-2XS-PCIe (4x AR8151) in a Proxmox VE host, with atl1c built from a DKMS tree carrying this change: the l2mtu-1600 traffic that panics the stock driver is dropped and counted with the patch applied, and received normally once the host MTU is raised to match.
This complements commit 36c2009d90f2 ("net: atl1c: fix soft lockup on out-of-range tpd_cons read"), which fixed the TX side of the same "host dies while the card resets" problem.
--- .../net/ethernet/atheros/atl1c/atl1c_main.c | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
drivers/net/ethernet/atheros/atl1c/atl1c_main.c +33 -0
@@ -1934,6 +1934,39 @@ static int atl1c_clean_rx(struct napi_struct *napi, int budget)break ; }atl1c_clean_rfd (rfd_ring, rrs, rfd_num); + +/* A link partner whose l2mtu is larger than ours can hand us a +* frame that does not fit the buffer the hardware was given: +* the descriptor reports the untruncated length while at most +* buffer_info->length bytes were written. skb_put() of such a +* length would pull in whatever the tail of the buffer holds +* and, past the end of the skb, trips skb_over_panic and takes +* the host down. Bound it by what the device actually wrote +* rather than by skb_tailroom(): the skb carries 64 bytes of +* slack for the DMA erratum, so the two are not the same. +* +* Frames shorter than an Ethernet header plus its FCS are +* rejected by the same test; before this, a length below +* ETH_FCS_LEN underflowed in skb_put(). +*/ +if (unlikely (length <ETH_HLEN +ETH_FCS_LEN || + length > buffer_info->length)) { +dev_core_stats_rx_dropped_inc (netdev); +if (netif_msg_rx_err (adapter)) +dev_warn_ratelimited (&pdev->dev, +"dropped rx frame: %u bytes, buffer %u\n" , + length, buffer_info->length); +kfree_skb_reason (skb,SKB_DROP_REASON_PKT_TOO_BIG ); +/* atl1c_clean_rfd() has already recycled the RFD, so +* count the drop as work: the refill at the end of the +* poll only runs when work_done is non-zero, and +* sustained oversized traffic would otherwise drain the +* ring and stop RX for good. +*/ + work_done++; +continue ; + } +skb_put (skb, length -ETH_FCS_LEN ); skb->protocol =eth_type_trans (skb, netdev);atl1c_rx_checksum (adapter, skb, rrs);
Signature · 1 line
2.53.0
PATCH v2 1/1 net: atl1c: drop oversized RX frames instead of panicking
atl1c sizes its receive buffers from the netdev MTU plus a fixed set of L2 overheads, which comes to 1522 bytes at the default MTU. A link partner that sends a longer frame - in practice a MikroTik CCR2004-1G-2XS-PCIe, whose RouterOS side defaults to l2mtu 1600 while the host stays at MTU 1500
- makes the length reported by the RX return descriptor exceed what the hardware wrote, and skb_put() then either includes bytes that were never received or trips skb_over_panic and takes the host down.
Compare the descriptor length against buffer_info->length, the length the hardware was given, rather than against skb_tailroom(): the skb carries 64 bytes of slack for the DMA erratum, so tailroom is larger than the DMA buffer and a frame in between would pass the check and still be delivered with a tail the device never wrote. The same test rejects frames shorter than ETH_HLEN + ETH_FCS_LEN; before this change a reported length below ETH_FCS_LEN underflowed in skb_put().
The frame is dropped with kfree_skb_reason(SKB_DROP_REASON_PKT_TOO_BIG) so drop_monitor and the kfree_skb tracepoint see it, and counted through dev_core_stats_rx_dropped_inc(), which survives atl1c_get_stats() overwriting the hardware counters on every read. It also counts as work:atl1c_clean_rfd() has already recycled the RFD, and the refill at the end of the poll only runs when work_done is non-zero, so sustained oversized traffic would otherwise drain the ring and stop RX.
Tested on a MikroTik CCR2004-1G-2XS-PCIe (4x AR8151) in a Proxmox VE host, with atl1c built from a DKMS tree carrying this change: the l2mtu-1600 traffic that panics the stock driver is dropped and counted with the patch applied, and received normally once the host MTU is raised to match.
This complements commit 36c2009d90f2 ("net: atl1c: fix soft lockup on out-of-range tpd_cons read"), which fixed the TX side of the same "host dies while the card resets" problem.
[ Federico Musto: 5.10.y has neither dev_core_stats_rx_dropped_inc() nor
kfree_skb_reason(): count the drop in netdev->rx_dropped, the counter dev_core_stats replaced, which dev_get_stats() adds to what atl1c_get_stats() returns, and free the skb with kfree_skb(). The RX loop is atl1c_clean_rx_irq() here: work_done is an int * and the refill at the end of the poll is gated on the local count, so the drop path bumps both. 5.10.y does not have the 64 bytes of RX slack from commit 86565682e905 ("atl1c: Work around the DMA RX overflow issue"), but the skb can still be larger than the buffer mapped for DMA, so the bound is the same and only the comment is reworded. Build-tested only, not run on hardware. ]
---
This replaces the 5.10 backport I sent on 2026-11-10 (v1, link below); please drop v1 if it was picked up.
v2:
- bump count in the drop path as well as *work_done. In 5.10.y the refill at the end of atl1c_clean_rx_irq() is gated on count, so with v1 a poll that only saw dropped frames did not refill, and sustained oversized traffic could still drain the RFD ring and stop RX.
- count the drop in netdev->rx_dropped instead of netdev->stats.rx_dropped, which atl1c_get_stats() overwrites on every read.
- free with kfree_skb() instead of dev_kfree_skb_any().
- keep the upstream commit message as is and describe the 5.10 changes in the note; v1 also gave wrong versions for the missing helpers.
- reference the upstream commit by its full id and reply to the FAILED mail, as asked there.
v1: https://lore.kernel.org/stable/[email protected]/
Build-tested on 5.10.274, x86_64 defconfig + CONFIG_ATL1C=m, gcc 14.2.0, W=1 C=1 with sparse 0.6.4: the same 30 warnings before and after, none new. Not run on hardware.
.../net/ethernet/atheros/atl1c/atl1c_main.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/net/ethernet/atheros/atl1c/atl1c_main.c +34 -0
@@ -1844,6 +1844,40 @@ rrs_checked:break ; }atl1c_clean_rfd (rfd_ring, rrs, rfd_num); + +/* A link partner whose l2mtu is larger than ours can hand us a +* frame that does not fit the buffer the hardware was given: +* the descriptor reports the untruncated length while at most +* buffer_info->length bytes were written. skb_put() of such a +* length would pull in whatever the tail of the buffer holds +* and, past the end of the skb, trips skb_over_panic and takes +* the host down. Bound it by what the device actually wrote +* rather than by skb_tailroom(): the skb can be larger than +* the buffer mapped for DMA, so the two are not the same. +* +* Frames shorter than an Ethernet header plus its FCS are +* rejected by the same test; before this, a length below +* ETH_FCS_LEN underflowed in skb_put(). +*/ +if (unlikely (length <ETH_HLEN +ETH_FCS_LEN || + length > buffer_info->length)) { +atomic_long_inc (&netdev->rx_dropped); +if (netif_msg_rx_err (adapter)) +dev_warn_ratelimited (&pdev->dev, +"dropped rx frame: %u bytes, buffer %u\n" , + length, buffer_info->length); +kfree_skb (skb); +/* atl1c_clean_rfd() has already recycled the RFD, so +* count the drop as work: the refill at the end of the +* poll only runs when count is non-zero, and +* sustained oversized traffic would otherwise drain the +* ring and stop RX for good. +*/ + (*work_done)++; + count++; +continue ; + } +skb_put (skb, length -ETH_FCS_LEN ); skb->protocol =eth_type_trans (skb, netdev);atl1c_rx_checksum (adapter, skb, rrs);
Signature · 1 line
2.54.0 (Apple Git-157)
Re: [PATCH 5.10.y v2] net: atl1c: drop oversized RX frames instead of panicking
Quoted 1 line
[PATCH 5.10.y v2] net: atl1c: drop oversized RX frames instead of panicking
Queued for 5.15 and 5.10, thanks.
Signature · 2 lines
Thanks, Sasha