Skip to content

Commit

Permalink
ipv6: Plug sk_buff leak in ipv6_rcv (net/ipv6/ip6_input.c)
Browse files Browse the repository at this point in the history
[ Upstream commit 71f6f6d ]

Commit 778d80b
(ipv6: Add disable_ipv6 sysctl to disable IPv6 operaion on specific interface)
seems to have introduced a leak of sk_buff's for ipv6 traffic,
at least in some configurations where idev is NULL, or when ipv6
is disabled via sysctl.

The problem is that if the first condition of the if-statement
returns non-NULL, it returns an skb with only one reference,
and when the other conditions apply, execution jumps to the "out"
label, which does not call kfree_skb for it.

To plug this leak, change to use the "drop" label instead.
(this relies on it being ok to call kfree_skb on NULL)
This also allows us to avoid calling rcu_read_unlock here,
and removes the only user of the "out" label.

Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
  • Loading branch information
Jesper Nilsson authored and Chris Wright committed Apr 2, 2009
1 parent ed421a6 commit c8289b1
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions net/ipv6/ip6_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL ||
!idev || unlikely(idev->cnf.disable_ipv6)) {
IP6_INC_STATS_BH(net, idev, IPSTATS_MIB_INDISCARDS);
rcu_read_unlock();
goto out;
goto drop;
}

memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm));
Expand Down Expand Up @@ -147,7 +146,6 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
drop:
rcu_read_unlock();
kfree_skb(skb);
out:
return 0;
}

Expand Down

0 comments on commit c8289b1

Please sign in to comment.