From: William Allen Simpson on 19 Jan 2010 04:20 Simon Arlott wrote: > The check for data only needs to apply where the packet length > could be increased by adding the MSS option. (The MSS option > itself applies to the sender's maximum receive size which is > not relevant to any data in its own packet.) > > This moves the check for (header size != packet size) to after > attempting to modify an existing MSS option. Another check is > needed before looking through the header to ensure it doesn't > claim to be larger than the packet size. > What's the path from tcp_v[4,6]_rcv() to these tests? 1) Header larger than the packet is already tested in about 5 places, and my patch "tcp: harmonize tcp_vx_rcv header length assumptions" tries to get them all down to just *one* test. 2) There certainly *can* be data on SYN. That code is already in 2.6.33.... > The ERROR level printk() is also removed as it can be triggered > by remote hosts and is not useful: > [4941777.937417] xt_TCPMSS: bad length (40 bytes) > [4941782.409724] xt_TCPMSS: bad length (40 bytes) > [4941790.762332] xt_TCPMSS: bad length (40 bytes) > > Signed-off-by: Simon Arlott <simon(a)fire.lp0.eu> > --- > net/netfilter/xt_TCPMSS.c | 21 +++++++++++---------- > 1 files changed, 11 insertions(+), 10 deletions(-) > > diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c > index eda64c1..76f92bf 100644 > --- a/net/netfilter/xt_TCPMSS.c > +++ b/net/netfilter/xt_TCPMSS.c > @@ -60,17 +60,9 @@ tcpmss_mangle_packet(struct sk_buff *skb, > tcplen = skb->len - tcphoff; > tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff); > > - /* Since it passed flags test in tcp match, we know it is is > - not a fragment, and has data >= tcp header length. SYN > - packets should not contain data: if they did, then we risk > - running over MTU, sending Frag Needed and breaking things > - badly. --RR */ > - if (tcplen != tcph->doff*4) { > - if (net_ratelimit()) > - printk(KERN_ERR "xt_TCPMSS: bad length (%u bytes)\n", > - skb->len); > + /* Header cannot be larger than the packet */ > + if (tcplen < tcph->doff*4) > return -1; > - } > > if (info->mss == XT_TCPMSS_CLAMP_PMTU) { > if (dst_mtu(skb_dst(skb)) <= minlen) { > @@ -115,6 +107,15 @@ tcpmss_mangle_packet(struct sk_buff *skb, > } > } > > + /* Since it passed flags test in tcp match, we know it is > + not a fragment, and has data >= tcp header length. SYN > + packets should not contain data: if they did, then we risk > + running over MTU, sending Frag Needed and breaking things > + badly. --RR > + */ > + if (tcplen > tcph->doff*4) > + return -1; > + > /* > * MSS Option not found ?! add it.. > */ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Patrick McHardy on 19 Jan 2010 04:40 William Allen Simpson wrote: > Simon Arlott wrote: >> The check for data only needs to apply where the packet length >> could be increased by adding the MSS option. (The MSS option >> itself applies to the sender's maximum receive size which is >> not relevant to any data in its own packet.) >> >> This moves the check for (header size != packet size) to after >> attempting to modify an existing MSS option. Another check is >> needed before looking through the header to ensure it doesn't >> claim to be larger than the packet size. >> > What's the path from tcp_v[4,6]_rcv() to these tests? > > 1) Header larger than the packet is already tested in about 5 places, > and my patch "tcp: harmonize tcp_vx_rcv header length assumptions" > tries to get them all down to just *one* test. We're talking about a netfilter module here, which has to deal with forwarded traffic and can only rely on the IP header checks done in ip_rcv(). -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Simon Arlott on 19 Jan 2010 07:50 On Tue, January 19, 2010 09:30, Patrick McHardy wrote: > William Allen Simpson wrote: >> Simon Arlott wrote: >>> This moves the check for (header size != packet size) to after >>> attempting to modify an existing MSS option. Another check is >>> needed before looking through the header to ensure it doesn't >>> claim to be larger than the packet size. >>> >> What's the path from tcp_v[4,6]_rcv() to these tests? >> >> 1) Header larger than the packet is already tested in about 5 places, >> and my patch "tcp: harmonize tcp_vx_rcv header length assumptions" >> tries to get them all down to just *one* test. > > We're talking about a netfilter module here, which has to deal > with forwarded traffic and can only rely on the IP header checks > done in ip_rcv(). My gateway (where these error messages occur) is running 2.6.29, and skb->len (from the prink) is 40 bytes. If this is 20 (IPv4 Header) + 20 (TCP Header) = 40 bytes, then there is no data and the header offset is wrong so it hasn't been checked. -- Simon Arlott -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Simon Arlott on 19 Jan 2010 08:00 On Tue, January 19, 2010 09:17, William Allen Simpson wrote: > Simon Arlott wrote: >> The check for data only needs to apply where the packet length >> could be increased by adding the MSS option. (The MSS option >> itself applies to the sender's maximum receive size which is >> not relevant to any data in its own packet.) >> >> This moves the check for (header size != packet size) to after >> attempting to modify an existing MSS option. Another check is >> needed before looking through the header to ensure it doesn't >> claim to be larger than the packet size. >> > > 2) There certainly *can* be data on SYN. That code is already in > 2.6.33.... I could change the comment too, but the same logic applies when there is data and no MSS option - the packet can't be increased in size if it would then exceed 576 bytes and/or the destination MTU. If it's possible to know that the packet can have an additional option added without exceeding MTU then this could be changed. The data part would need to be moved to make space at the end of the header. -- Simon Arlott -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Patrick McHardy on 19 Jan 2010 08:00 Simon Arlott wrote: > On Tue, January 19, 2010 09:30, Patrick McHardy wrote: >> William Allen Simpson wrote: >>> Simon Arlott wrote: >>>> This moves the check for (header size != packet size) to after >>>> attempting to modify an existing MSS option. Another check is >>>> needed before looking through the header to ensure it doesn't >>>> claim to be larger than the packet size. >>>> >>> What's the path from tcp_v[4,6]_rcv() to these tests? >>> >>> 1) Header larger than the packet is already tested in about 5 places, >>> and my patch "tcp: harmonize tcp_vx_rcv header length assumptions" >>> tries to get them all down to just *one* test. >> We're talking about a netfilter module here, which has to deal >> with forwarded traffic and can only rely on the IP header checks >> done in ip_rcv(). > > My gateway (where these error messages occur) is running 2.6.29, > and skb->len (from the prink) is 40 bytes. > > If this is 20 (IPv4 Header) + 20 (TCP Header) = 40 bytes, then there > is no data and the header offset is wrong so it hasn't been checked. That's odd. If the packet is really only 40 bytes large, then there are no TCP options, so your patch shouldn't have any effect. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|
Next
|
Last
Pages: 1 2 3 4 Prev: loan at 2% interest rate Next: cmd64x: fix PIO and MWDMA timings calculations |