diff options
author | Nicolas Dichtel <nicolas.dichtel@6wind.com> | 2013-11-14 09:47:03 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-11-14 17:04:38 -0500 |
commit | 1e9f3d6f1c403dd2b6270f654b4747147aa2306f (patch) | |
tree | 5919ae67befcdb3de8aee7330cafb789bec37d19 /net/ipv6 | |
parent | f7cb8886335dea39fa31bb701700361f1aa7a6ea (diff) |
ip6tnl: fix use after free of fb_tnl_dev
Bug has been introduced by commit bb8140947a24 ("ip6tnl: allow to use rtnl ops
on fb tunnel").
When ip6_tunnel.ko is unloaded, FB device is delete by rtnl_link_unregister()
and then we try to use the pointer in ip6_tnl_destroy_tunnels().
Let's add an handler for dellink, which will never remove the FB tunnel. With
this patch it will no more be possible to remove it via 'ip link del ip6tnl0',
but it's safer.
The same fix was already proposed by Willem de Bruijn <willemb@google.com> for
sit interfaces.
CC: Willem de Bruijn <willemb@google.com>
Reported-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/ip6_tunnel.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 583b77e2f69b..c1e11b5d6ccc 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
@@ -1635,6 +1635,15 @@ static int ip6_tnl_changelink(struct net_device *dev, struct nlattr *tb[], | |||
1635 | return ip6_tnl_update(t, &p); | 1635 | return ip6_tnl_update(t, &p); |
1636 | } | 1636 | } |
1637 | 1637 | ||
1638 | static void ip6_tnl_dellink(struct net_device *dev, struct list_head *head) | ||
1639 | { | ||
1640 | struct net *net = dev_net(dev); | ||
1641 | struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); | ||
1642 | |||
1643 | if (dev != ip6n->fb_tnl_dev) | ||
1644 | unregister_netdevice_queue(dev, head); | ||
1645 | } | ||
1646 | |||
1638 | static size_t ip6_tnl_get_size(const struct net_device *dev) | 1647 | static size_t ip6_tnl_get_size(const struct net_device *dev) |
1639 | { | 1648 | { |
1640 | return | 1649 | return |
@@ -1699,6 +1708,7 @@ static struct rtnl_link_ops ip6_link_ops __read_mostly = { | |||
1699 | .validate = ip6_tnl_validate, | 1708 | .validate = ip6_tnl_validate, |
1700 | .newlink = ip6_tnl_newlink, | 1709 | .newlink = ip6_tnl_newlink, |
1701 | .changelink = ip6_tnl_changelink, | 1710 | .changelink = ip6_tnl_changelink, |
1711 | .dellink = ip6_tnl_dellink, | ||
1702 | .get_size = ip6_tnl_get_size, | 1712 | .get_size = ip6_tnl_get_size, |
1703 | .fill_info = ip6_tnl_fill_info, | 1713 | .fill_info = ip6_tnl_fill_info, |
1704 | }; | 1714 | }; |
@@ -1715,9 +1725,9 @@ static struct xfrm6_tunnel ip6ip6_handler __read_mostly = { | |||
1715 | .priority = 1, | 1725 | .priority = 1, |
1716 | }; | 1726 | }; |
1717 | 1727 | ||
1718 | static void __net_exit ip6_tnl_destroy_tunnels(struct ip6_tnl_net *ip6n) | 1728 | static void __net_exit ip6_tnl_destroy_tunnels(struct net *net) |
1719 | { | 1729 | { |
1720 | struct net *net = dev_net(ip6n->fb_tnl_dev); | 1730 | struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); |
1721 | struct net_device *dev, *aux; | 1731 | struct net_device *dev, *aux; |
1722 | int h; | 1732 | int h; |
1723 | struct ip6_tnl *t; | 1733 | struct ip6_tnl *t; |
@@ -1785,10 +1795,8 @@ err_alloc_dev: | |||
1785 | 1795 | ||
1786 | static void __net_exit ip6_tnl_exit_net(struct net *net) | 1796 | static void __net_exit ip6_tnl_exit_net(struct net *net) |
1787 | { | 1797 | { |
1788 | struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); | ||
1789 | |||
1790 | rtnl_lock(); | 1798 | rtnl_lock(); |
1791 | ip6_tnl_destroy_tunnels(ip6n); | 1799 | ip6_tnl_destroy_tunnels(net); |
1792 | rtnl_unlock(); | 1800 | rtnl_unlock(); |
1793 | } | 1801 | } |
1794 | 1802 | ||