Skip to content

Commit

Permalink
act_nat: not all of the ICMP packets need an IP header payload
Browse files Browse the repository at this point in the history
not all of the ICMP packets need an IP header payload, so we check the length
of the skbs only when the packets should have an IP header payload.

Based upon analysis and initial patch by Rodrigo Partearroyo González.

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
----
 net/sched/act_nat.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Changli Gao authored and David S. Miller committed Jul 13, 2010
1 parent c4363d6 commit 70c2efa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/sched/act_nat.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a,
{
struct icmphdr *icmph;

if (!pskb_may_pull(skb, ihl + sizeof(*icmph) + sizeof(*iph)))
if (!pskb_may_pull(skb, ihl + sizeof(*icmph)))
goto drop;

icmph = (void *)(skb_network_header(skb) + ihl);
Expand All @@ -215,6 +215,9 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a,
(icmph->type != ICMP_PARAMETERPROB))
break;

if (!pskb_may_pull(skb, ihl + sizeof(*icmph) + sizeof(*iph)))
goto drop;

iph = (void *)(icmph + 1);
if (egress)
addr = iph->daddr;
Expand Down

0 comments on commit 70c2efa

Please sign in to comment.