netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xt_TCPMSS: SYN packets are allowed to contain data
@ 2010-01-18 21:08 Simon Arlott
  2010-01-19  9:17 ` William Allen Simpson
  0 siblings, 1 reply; 19+ messages in thread
From: Simon Arlott @ 2010-01-18 21:08 UTC (permalink / raw)
  To: netdev, Patrick McHardy; +Cc: Linux Kernel Mailing List

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.

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@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..
 	 */
-- 
1.6.3.3

-- 
Simon Arlott

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2010-02-02 14:34 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-18 21:08 [PATCH] xt_TCPMSS: SYN packets are allowed to contain data Simon Arlott
2010-01-19  9:17 ` William Allen Simpson
2010-01-19  9:30   ` Patrick McHardy
2010-01-19 12:43     ` Simon Arlott
2010-01-19 12:53       ` Patrick McHardy
2010-01-19 12:50   ` Simon Arlott
2010-01-19 15:44     ` William Allen Simpson
2010-01-20 12:59       ` Simon Arlott
2010-01-20 21:21         ` Simon Arlott
2010-01-20 21:39           ` Jan Engelhardt
2010-01-20 21:41             ` Jan Engelhardt
2010-01-20 21:51               ` Simon Arlott
2010-01-20 22:22                 ` Amos Jeffries
2010-01-20 23:14               ` Patrick McHardy
2010-01-21 12:47                 ` Simon Arlott
2010-01-21 12:58                   ` Jan Engelhardt
2010-01-21 13:02                   ` Patrick McHardy
2010-01-21 20:13                     ` Simon Arlott
2010-02-02 14:34                       ` Patrick McHardy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).