]> git.dujemihanovic.xyz Git - linux.git/commitdiff
net: check dev->gso_max_size in gso_features_check()
authorEric Dumazet <edumazet@google.com>
Tue, 19 Dec 2023 12:53:31 +0000 (12:53 +0000)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 21 Dec 2023 09:15:10 +0000 (10:15 +0100)
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>
net/core/dev.c

index c879246be48d82f83072a48b19ec073df8efe27b..ad20bebe153fc7d16a4e3ce8ebeabf075acacb4a 100644 (file)
@@ -3472,6 +3472,9 @@ static netdev_features_t gso_features_check(const struct sk_buff *skb,
        if (gso_segs > READ_ONCE(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;