]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: stmmac: Correctly handle Rx checksum offload errors
authorOleksij Rempel <o.rempel@pengutronix.de>
Mon, 18 Aug 2025 09:02:15 +0000 (11:02 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:37:04 +0000 (15:37 -0500)
[ Upstream commit ee0aace5f844ef59335148875d05bec8764e71e8 ]

The stmmac_rx function would previously set skb->ip_summed to
CHECKSUM_UNNECESSARY if hardware checksum offload (CoE) was enabled
and the packet was of a known IP ethertype.

However, this logic failed to check if the hardware had actually
reported a checksum error. The hardware status, indicating a header or
payload checksum failure, was being ignored at this stage. This could
cause corrupt packets to be passed up the network stack as valid.

This patch corrects the logic by checking the `csum_none` status flag,
which is set when the hardware reports a checksum error. If this flag
is set, skb->ip_summed is now correctly set to CHECKSUM_NONE,
ensuring the kernel's network stack will perform its own validation and
properly handle the corrupt packet.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://patch.msgid.link/20250818090217.2789521-2-o.rempel@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index b9f55e4e360fb9ff665789c98eda3a257d89c054..7a375de2258c46ca6aaf8ef42d5a5ee43a9512fb 100644 (file)
@@ -5735,7 +5735,8 @@ drain_data:
 
                skb->protocol = eth_type_trans(skb, priv->dev);
 
-               if (unlikely(!coe) || !stmmac_has_ip_ethertype(skb))
+               if (unlikely(!coe) || !stmmac_has_ip_ethertype(skb) ||
+                   (status & csum_none))
                        skb_checksum_none_assert(skb);
                else
                        skb->ip_summed = CHECKSUM_UNNECESSARY;