Skip to content

Commit

Permalink
ipv6: fix a potential use after free in sit.c
Browse files Browse the repository at this point in the history
pskb_may_pull() maybe change skb->data and make iph pointer oboslete,
fix it by geting ip header length directly.

Fixes: ca15a07 (sit: generate icmpv6 error when receiving icmpv4 error)
Cc: Oussama Ghorbel <[email protected]>
Signed-off-by: Li RongQing <[email protected]>
Acked-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Li RongQing authored and davem330 committed Oct 18, 2014
1 parent fc6fb41 commit a6d4518
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/ipv6/sit.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,11 @@ static void ipip6_tunnel_uninit(struct net_device *dev)
*/
static int ipip6_err_gen_icmpv6_unreach(struct sk_buff *skb)
{
const struct iphdr *iph = (const struct iphdr *) skb->data;
int ihl = ((const struct iphdr *)skb->data)->ihl*4;
struct rt6_info *rt;
struct sk_buff *skb2;

if (!pskb_may_pull(skb, iph->ihl * 4 + sizeof(struct ipv6hdr) + 8))
if (!pskb_may_pull(skb, ihl + sizeof(struct ipv6hdr) + 8))
return 1;

skb2 = skb_clone(skb, GFP_ATOMIC);
Expand All @@ -498,7 +498,7 @@ static int ipip6_err_gen_icmpv6_unreach(struct sk_buff *skb)
return 1;

skb_dst_drop(skb2);
skb_pull(skb2, iph->ihl * 4);
skb_pull(skb2, ihl);
skb_reset_network_header(skb2);

rt = rt6_lookup(dev_net(skb->dev), &ipv6_hdr(skb2)->saddr, NULL, 0, 0);
Expand Down

0 comments on commit a6d4518

Please sign in to comment.