aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_gre.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-02-27 02:51:04 -0500
committerDavid S. Miller <davem@davemloft.net>2008-02-27 02:51:04 -0500
commitb37d428b24ad38034f56b614de05686ba151b614 (patch)
treedfa41745c88edb80a47c246d13a899ee06a7510f /net/ipv4/ip_gre.c
parentd9595a7b9c777d45a74774f1428c263a0a47f4c0 (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/ipv4/ip_gre.c')
-rw-r--r--net/ipv4/ip_gre.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 906cb1ada4c3..e7821ba7a9a0 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -266,20 +266,24 @@ static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int
266 if (!dev) 266 if (!dev)
267 return NULL; 267 return NULL;
268 268
269 if (strchr(name, '%')) {
270 if (dev_alloc_name(dev, name) < 0)
271 goto failed_free;
272 }
273
269 dev->init = ipgre_tunnel_init; 274 dev->init = ipgre_tunnel_init;
270 nt = netdev_priv(dev); 275 nt = netdev_priv(dev);
271 nt->parms = *parms; 276 nt->parms = *parms;
272 277
273 if (register_netdevice(dev) < 0) { 278 if (register_netdevice(dev) < 0)
274 free_netdev(dev); 279 goto failed_free;
275 goto failed;
276 }
277 280
278 dev_hold(dev); 281 dev_hold(dev);
279 ipgre_tunnel_link(nt); 282 ipgre_tunnel_link(nt);
280 return nt; 283 return nt;
281 284
282failed: 285failed_free:
286 free_netdev(dev);
283 return NULL; 287 return NULL;
284} 288}
285 289