Skip to content

Commit

Permalink
ipv4: Put proper checks into icmp_socket_deliver().
Browse files Browse the repository at this point in the history
All handler->err() routines expect that we've done a pskb_may_pull()
test to make sure that IP header length + 8 bytes can be safely
pulled.

Reported-by: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jul 12, 2012
1 parent 065f5f9 commit f0a70e9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions net/ipv4/icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,12 @@ static void icmp_socket_deliver(struct sk_buff *skb, u32 info)
const struct net_protocol *ipprot;
int protocol = iph->protocol;

/* Checkin full IP header plus 8 bytes of protocol to
* avoid additional coding at protocol handlers.
*/
if (!pskb_may_pull(skb, iph->ihl * 4 + 8))
return;

raw_icmp_error(skb, protocol, info);

rcu_read_lock();
Expand Down Expand Up @@ -733,12 +739,6 @@ static void icmp_unreach(struct sk_buff *skb)
goto out;
}

/* Checkin full IP header plus 8 bytes of protocol to
* avoid additional coding at protocol handlers.
*/
if (!pskb_may_pull(skb, iph->ihl * 4 + 8))
goto out;

icmp_socket_deliver(skb, info);

out:
Expand Down

0 comments on commit f0a70e9

Please sign in to comment.