All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Remove redundant TCP header checks from xt_TCPOPTSTRIP
@ 2013-06-10  3:59 Phil Oester
  2013-06-10 18:15 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Oester @ 2013-06-10  3:59 UTC (permalink / raw)
  To: netfilter-devel; +Cc: pablo

[-- Attachment #1: Type: text/plain, Size: 612 bytes --]

In commit bc6bcb59 ("netfilter: xt_TCPOPTSTRIP: fix possible mangling beyond
packet boundary"), a check for short TCP header or malformed packet was added.
This check is unnecessary, as these packets are already handled in the tcp_error
function of nf_conntrack_proto_tcp.c (see /* Not whole TCP header or malformed
packet */).  In addition, there was an error in the check which was added (len
is being calculated incorrectly).  In my testing, ALL packets are being dropped
by the TCPOPTSTRIP target at present.  Revert the unnecessary/incorrect checks.

Phil

Signed-off-by: Phil Oester <kernel@linuxace.com>


[-- Attachment #2: patch-revert-bc6bcb59d --]
[-- Type: text/plain, Size: 745 bytes --]

diff --git a/net/netfilter/xt_TCPOPTSTRIP.c b/net/netfilter/xt_TCPOPTSTRIP.c
index 1eb1a44..2d43be9f 100644
--- a/net/netfilter/xt_TCPOPTSTRIP.c
+++ b/net/netfilter/xt_TCPOPTSTRIP.c
@@ -38,7 +38,6 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
 	struct tcphdr *tcph;
 	u_int16_t n, o;
 	u_int8_t *opt;
-	int len;
 
 	/* This is a fragment, no TCP header is available */
 	if (par->fragoff != 0)
@@ -47,11 +46,6 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
 	if (!skb_make_writable(skb, skb->len))
 		return NF_DROP;
 
-	len = skb->len - tcphoff;
-	if (len < (int)sizeof(struct tcphdr) ||
-	    tcp_hdr(skb)->doff * 4 > len)
-		return NF_DROP;
-
 	tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
 	opt  = (u_int8_t *)tcph;
 

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

* Re: [PATCH] Remove redundant TCP header checks from xt_TCPOPTSTRIP
  2013-06-10  3:59 [PATCH] Remove redundant TCP header checks from xt_TCPOPTSTRIP Phil Oester
@ 2013-06-10 18:15 ` Pablo Neira Ayuso
  2013-06-10 20:22   ` Florian Westphal
  0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2013-06-10 18:15 UTC (permalink / raw)
  To: Phil Oester; +Cc: netfilter-devel

On Sun, Jun 09, 2013 at 11:59:48PM -0400, Phil Oester wrote:
> In commit bc6bcb59 ("netfilter: xt_TCPOPTSTRIP: fix possible mangling beyond
> packet boundary"), a check for short TCP header or malformed packet was added.
> This check is unnecessary, as these packets are already handled in the tcp_error
> function of nf_conntrack_proto_tcp.c (see /* Not whole TCP header or malformed
> packet */).

We cannot assume nf_conntrack is loaded. We have to support stateless
setups as well.

> In addition, there was an error in the check which was added (len
> is being calculated incorrectly).  In my testing, ALL packets are being dropped
> by the TCPOPTSTRIP target at present.  Revert the unnecessary/incorrect checks.

Then, we have to fix the wrong calculation. I cannot reproduce this
here.

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

* Re: [PATCH] Remove redundant TCP header checks from xt_TCPOPTSTRIP
  2013-06-10 18:15 ` Pablo Neira Ayuso
@ 2013-06-10 20:22   ` Florian Westphal
  0 siblings, 0 replies; 3+ messages in thread
From: Florian Westphal @ 2013-06-10 20:22 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: Phil Oester, netfilter-devel

Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> We cannot assume nf_conntrack is loaded. We have to support stateless
> setups as well.
> 
> > In addition, there was an error in the check which was added (len
> > is being calculated incorrectly).  In my testing, ALL packets are being dropped
> > by the TCPOPTSTRIP target at present.  Revert the unnecessary/incorrect checks.
> 
> Then, we have to fix the wrong calculation. I cannot reproduce this
> here.

Its most likely due to tcp_hdr() use, it only works for local packets.

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

end of thread, other threads:[~2013-06-10 20:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-10  3:59 [PATCH] Remove redundant TCP header checks from xt_TCPOPTSTRIP Phil Oester
2013-06-10 18:15 ` Pablo Neira Ayuso
2013-06-10 20:22   ` Florian Westphal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.