diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-02-27 02:51:04 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-02-27 02:51:04 -0500 |
commit | b37d428b24ad38034f56b614de05686ba151b614 (patch) | |
tree | dfa41745c88edb80a47c246d13a899ee06a7510f /net/ipv6/ip6_tunnel.c | |
parent | d9595a7b9c777d45a74774f1428c263a0a47f4c0 (diff) |
[INET]: Don't create tunnels with '%' in name.
Four tunnel drivers (ip_gre, ipip, ip6_tunnel and sit) can receive a
pre-defined name for a device from the userspace. Since these drivers
call the register_netdevice() (rtnl_lock, is held), which does _not_
generate the device's name, this name may contain a '%' character.
Not sure how bad is this to have a device with a '%' in its name, but
all the other places either use the register_netdev(), which call the
dev_alloc_name(), or explicitly call the dev_alloc_name() before
registering, i.e. do not allow for such names.
This had to be prior to the commit 34cc7b, but I forgot to number the
patches and this one got lost, sorry.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/ip6_tunnel.c')
-rw-r--r-- | net/ipv6/ip6_tunnel.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 2a124e9a1b2d..78f438880923 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
@@ -238,17 +238,24 @@ static struct ip6_tnl *ip6_tnl_create(struct ip6_tnl_parm *p) | |||
238 | if (dev == NULL) | 238 | if (dev == NULL) |
239 | goto failed; | 239 | goto failed; |
240 | 240 | ||
241 | if (strchr(name, '%')) { | ||
242 | if (dev_alloc_name(dev, name) < 0) | ||
243 | goto failed_free; | ||
244 | } | ||
245 | |||
241 | t = netdev_priv(dev); | 246 | t = netdev_priv(dev); |
242 | dev->init = ip6_tnl_dev_init; | 247 | dev->init = ip6_tnl_dev_init; |
243 | t->parms = *p; | 248 | t->parms = *p; |
244 | 249 | ||
245 | if ((err = register_netdevice(dev)) < 0) { | 250 | if ((err = register_netdevice(dev)) < 0) |
246 | free_netdev(dev); | 251 | goto failed_free; |
247 | goto failed; | 252 | |
248 | } | ||
249 | dev_hold(dev); | 253 | dev_hold(dev); |
250 | ip6_tnl_link(t); | 254 | ip6_tnl_link(t); |
251 | return t; | 255 | return t; |
256 | |||
257 | failed_free: | ||
258 | free_netdev(dev); | ||
252 | failed: | 259 | failed: |
253 | return NULL; | 260 | return NULL; |
254 | } | 261 | } |