Skip to content

Commit

Permalink
netfilter: xt_TCPOPTSTRIP: don't use tcp_hdr()
Browse files Browse the repository at this point in the history
In (bc6bcb5 netfilter: xt_TCPOPTSTRIP: fix possible mangling beyond
packet boundary), the use of tcp_hdr was introduced. However, we
cannot assume that skb->transport_header is set for non-local packets.

Cc: Florian Westphal <fw@strlen.de>
Reported-by: Phil Oester <kernel@linuxace.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Pablo Neira Ayuso committed Jun 10, 2013
1 parent a8241c6 commit ed82c43
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/netfilter/xt_TCPOPTSTRIP.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
return NF_DROP;

len = skb->len - tcphoff;
if (len < (int)sizeof(struct tcphdr) ||
tcp_hdr(skb)->doff * 4 > len)
if (len < (int)sizeof(struct tcphdr))
return NF_DROP;

tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
if (tcph->doff * 4 > len)
return NF_DROP;

opt = (u_int8_t *)tcph;

/*
Expand Down

0 comments on commit ed82c43

Please sign in to comment.