All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ip6_gre: don't allow to remove the fb_tunnel_dev
@ 2014-04-14 15:11 Nicolas Dichtel
  2014-04-15  4:04 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Dichtel @ 2014-04-14 15:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, Nicolas Dichtel, Dmitry Kozlov

It's possible to remove the FB tunnel with the command 'ip link del ip6gre0' but
this is unsafe, the module always supposes that this device exists. For example,
ip6gre_tunnel_lookup() may use it unconditionally.

Let's add a rtnl handler for dellink, which will never remove the FB tunnel (we
let ip6gre_destroy_tunnels() do the job).

Introduced by commit c12b395a4664 ("gre: Support GRE over IPv6").

CC: Dmitry Kozlov <xeb@mail.ru>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/ipv6/ip6_gre.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index c98338b81d30..9d921462b57f 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -1559,6 +1559,15 @@ static int ip6gre_changelink(struct net_device *dev, struct nlattr *tb[],
 	return 0;
 }
 
+static void ip6gre_dellink(struct net_device *dev, struct list_head *head)
+{
+	struct net *net = dev_net(dev);
+	struct ip6gre_net *ign = net_generic(net, ip6gre_net_id);
+
+	if (dev != ign->fb_tunnel_dev)
+		unregister_netdevice_queue(dev, head);
+}
+
 static size_t ip6gre_get_size(const struct net_device *dev)
 {
 	return
@@ -1636,6 +1645,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
 	.validate	= ip6gre_tunnel_validate,
 	.newlink	= ip6gre_newlink,
 	.changelink	= ip6gre_changelink,
+	.dellink	= ip6gre_dellink,
 	.get_size	= ip6gre_get_size,
 	.fill_info	= ip6gre_fill_info,
 };
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ip6_gre: don't allow to remove the fb_tunnel_dev
  2014-04-14 15:11 [PATCH] ip6_gre: don't allow to remove the fb_tunnel_dev Nicolas Dichtel
@ 2014-04-15  4:04 ` David Miller
  2014-04-15  7:57   ` Nicolas Dichtel
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2014-04-15  4:04 UTC (permalink / raw)
  To: nicolas.dichtel; +Cc: netdev, xeb

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date: Mon, 14 Apr 2014 17:11:38 +0200

> It's possible to remove the FB tunnel with the command 'ip link del ip6gre0' but
> this is unsafe, the module always supposes that this device exists. For example,
> ip6gre_tunnel_lookup() may use it unconditionally.
> 
> Let's add a rtnl handler for dellink, which will never remove the FB tunnel (we
> let ip6gre_destroy_tunnels() do the job).
> 
> Introduced by commit c12b395a4664 ("gre: Support GRE over IPv6").
> 
> CC: Dmitry Kozlov <xeb@mail.ru>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

I don't see how we ever get rid of fb_tunnel_dev and can therefore
remove the module successfully.

It is created by the per-netns initialization, but since it isn't
added to the hashes I don't see how the per-netns exit code can
end up unregistering and freeing it up.

How is this supposed to work?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ip6_gre: don't allow to remove the fb_tunnel_dev
  2014-04-15  4:04 ` David Miller
@ 2014-04-15  7:57   ` Nicolas Dichtel
  2014-04-15 18:56     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Dichtel @ 2014-04-15  7:57 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, xeb

Le 15/04/2014 06:04, David Miller a écrit :
> From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> Date: Mon, 14 Apr 2014 17:11:38 +0200
>
>> It's possible to remove the FB tunnel with the command 'ip link del ip6gre0' but
>> this is unsafe, the module always supposes that this device exists. For example,
>> ip6gre_tunnel_lookup() may use it unconditionally.
>>
>> Let's add a rtnl handler for dellink, which will never remove the FB tunnel (we
>> let ip6gre_destroy_tunnels() do the job).
>>
>> Introduced by commit c12b395a4664 ("gre: Support GRE over IPv6").
>>
>> CC: Dmitry Kozlov <xeb@mail.ru>
>> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
>
> I don't see how we ever get rid of fb_tunnel_dev and can therefore
> remove the module successfully.
>
> It is created by the per-netns initialization, but since it isn't
> added to the hashes I don't see how the per-netns exit code can
> end up unregistering and freeing it up.
>
> How is this supposed to work?
It is added to the hashes in ip6gre_init_net() in bucket [0][0]:
#define tunnels_wc      tunnels[0]
[snip]
         rcu_assign_pointer(ign->tunnels_wc[0],
                            netdev_priv(ign->fb_tunnel_dev));

Thus the tunnel is deleted by the loop in ip6gre_destroy_tunnels().

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ip6_gre: don't allow to remove the fb_tunnel_dev
  2014-04-15  7:57   ` Nicolas Dichtel
@ 2014-04-15 18:56     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-04-15 18:56 UTC (permalink / raw)
  To: nicolas.dichtel; +Cc: netdev, xeb

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date: Tue, 15 Apr 2014 09:57:28 +0200

> Le 15/04/2014 06:04, David Miller a écrit :
>> From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
>> Date: Mon, 14 Apr 2014 17:11:38 +0200
>>
>>> It's possible to remove the FB tunnel with the command 'ip link del
>>> ip6gre0' but
>>> this is unsafe, the module always supposes that this device
>>> exists. For example,
>>> ip6gre_tunnel_lookup() may use it unconditionally.
>>>
>>> Let's add a rtnl handler for dellink, which will never remove the FB
>>> tunnel (we
>>> let ip6gre_destroy_tunnels() do the job).
>>>
>>> Introduced by commit c12b395a4664 ("gre: Support GRE over IPv6").
>>>
>>> CC: Dmitry Kozlov <xeb@mail.ru>
>>> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
>>
>> I don't see how we ever get rid of fb_tunnel_dev and can therefore
>> remove the module successfully.
>>
>> It is created by the per-netns initialization, but since it isn't
>> added to the hashes I don't see how the per-netns exit code can
>> end up unregistering and freeing it up.
>>
>> How is this supposed to work?
> It is added to the hashes in ip6gre_init_net() in bucket [0][0]:
> #define tunnels_wc      tunnels[0]
> [snip]
>         rcu_assign_pointer(ign->tunnels_wc[0],
>                            netdev_priv(ign->fb_tunnel_dev));
> 
> Thus the tunnel is deleted by the loop in ip6gre_destroy_tunnels().

Thanks for explaining, I missed that bit.  Applied and queued up for -stable,
thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-04-15 18:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-14 15:11 [PATCH] ip6_gre: don't allow to remove the fb_tunnel_dev Nicolas Dichtel
2014-04-15  4:04 ` David Miller
2014-04-15  7:57   ` Nicolas Dichtel
2014-04-15 18:56     ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.