summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2023-12-19 12:53:31 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-01-08 11:27:34 +0100
commit0ab47ec3874a88e75ecca7be8994d41823c3b560 (patch)
treee743478db2c4bda4be5f44f2623c67a2c010d087
parente2be74aa42c66aa26cca41998c36df35d0c729c9 (diff)
downloadlinux-stable-0ab47ec3874a88e75ecca7be8994d41823c3b560.tar.gz
linux-stable-0ab47ec3874a88e75ecca7be8994d41823c3b560.tar.bz2
linux-stable-0ab47ec3874a88e75ecca7be8994d41823c3b560.zip
net: check dev->gso_max_size in gso_features_check()
[ Upstream commit 24ab059d2ebd62fdccc43794796f6ffbabe49ebc ] Some drivers might misbehave if TSO packets get too big. GVE for instance uses a 16bit field in its TX descriptor, and will do bad things if a packet is bigger than 2^16 bytes. Linux TCP stack honors dev->gso_max_size, but there are other ways for too big packets to reach an ndo_start_xmit() handler : virtio_net, af_packet, GRO... Add a generic check in gso_features_check() and fallback to GSO when needed. gso_max_size was added in the blamed commit. Fixes: 82cc1a7a5687 ("[NET]: Add per-connection option to set max TSO frame size") Signed-off-by: Eric Dumazet <edumazet@google.com> Link: https://lore.kernel.org/r/20231219125331.4127498-1-edumazet@google.com Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--net/core/dev.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index ea05db68aa95..b5c9648c2192 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3200,6 +3200,9 @@ static netdev_features_t gso_features_check(const struct sk_buff *skb,
if (gso_segs > dev->gso_max_segs)
return features & ~NETIF_F_GSO_MASK;
+ if (unlikely(skb->len >= READ_ONCE(dev->gso_max_size)))
+ return features & ~NETIF_F_GSO_MASK;
+
if (!skb_shinfo(skb)->gso_type) {
skb_warn_bad_offload(skb);
return features & ~NETIF_F_GSO_MASK;