* [TCP]: Reset gso_segs if packet is dodgy
@ 2006-06-30 2:00 Herbert Xu
2006-06-30 3:11 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Herbert Xu @ 2006-06-30 2:00 UTC (permalink / raw)
To: David S. Miller, netdev
Hi Dave:
I forgot to verify gso_segs on packets from untrusted sources. In fact
looking around it seems that gso_segs is used by exactly one driver outside
of the TCP stack. In fact it also happens to be a virtual driver: s390/qeth.
Since the only other GSO user we have at the moment -- UFO, doesn't even set
gso_segs, I'd like to move it to skb->cb and get rid of this. However, for
now let's simply reset it in tcp_tso_segment.
[TCP]: Reset gso_segs if packet is dodgy
I wasn't paranoid enough in verifying GSO information. A bogus gso_segs
could upset drivers as much as a bogus header would. Let's reset it in
the per-protocol gso_segment functions.
I didn't verify gso_size because that can be verified by the source of
the dodgy packets.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 0336422..0bb0ac9 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2166,13 +2166,19 @@ struct sk_buff *tcp_tso_segment(struct s
if (!pskb_may_pull(skb, thlen))
goto out;
- segs = NULL;
- if (skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST))
- goto out;
-
oldlen = (u16)~skb->len;
__skb_pull(skb, thlen);
+ if (skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST)) {
+ /* Packet is from an untrusted source, reset gso_segs. */
+ int mss = skb_shinfo(skb)->gso_size;
+
+ skb_shinfo(skb)->gso_segs = (skb->len + mss - 1) / mss;
+
+ segs = NULL;
+ goto out;
+ }
+
segs = skb_segment(skb, features);
if (IS_ERR(segs))
goto out;
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [TCP]: Reset gso_segs if packet is dodgy
2006-06-30 2:00 [TCP]: Reset gso_segs if packet is dodgy Herbert Xu
@ 2006-06-30 3:11 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2006-06-30 3:11 UTC (permalink / raw)
To: herbert; +Cc: netdev
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Fri, 30 Jun 2006 12:00:44 +1000
> [TCP]: Reset gso_segs if packet is dodgy
>
> I wasn't paranoid enough in verifying GSO information. A bogus gso_segs
> could upset drivers as much as a bogus header would. Let's reset it in
> the per-protocol gso_segment functions.
>
> I didn't verify gso_size because that can be verified by the source of
> the dodgy packets.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Applied, thanks Herbert.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-06-30 3:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-30 2:00 [TCP]: Reset gso_segs if packet is dodgy Herbert Xu
2006-06-30 3:11 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox