Commit b37d428b authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller

[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: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d9595a7b
...@@ -266,20 +266,24 @@ static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int ...@@ -266,20 +266,24 @@ static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int
if (!dev) if (!dev)
return NULL; return NULL;
if (strchr(name, '%')) {
if (dev_alloc_name(dev, name) < 0)
goto failed_free;
}
dev->init = ipgre_tunnel_init; dev->init = ipgre_tunnel_init;
nt = netdev_priv(dev); nt = netdev_priv(dev);
nt->parms = *parms; nt->parms = *parms;
if (register_netdevice(dev) < 0) { if (register_netdevice(dev) < 0)
free_netdev(dev); goto failed_free;
goto failed;
}
dev_hold(dev); dev_hold(dev);
ipgre_tunnel_link(nt); ipgre_tunnel_link(nt);
return nt; return nt;
failed: failed_free:
free_netdev(dev);
return NULL; return NULL;
} }
......
...@@ -228,20 +228,24 @@ static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int c ...@@ -228,20 +228,24 @@ static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int c
if (dev == NULL) if (dev == NULL)
return NULL; return NULL;
if (strchr(name, '%')) {
if (dev_alloc_name(dev, name) < 0)
goto failed_free;
}
nt = netdev_priv(dev); nt = netdev_priv(dev);
dev->init = ipip_tunnel_init; dev->init = ipip_tunnel_init;
nt->parms = *parms; nt->parms = *parms;
if (register_netdevice(dev) < 0) { if (register_netdevice(dev) < 0)
free_netdev(dev); goto failed_free;
goto failed;
}
dev_hold(dev); dev_hold(dev);
ipip_tunnel_link(nt); ipip_tunnel_link(nt);
return nt; return nt;
failed: failed_free:
free_netdev(dev);
return NULL; return NULL;
} }
......
...@@ -238,17 +238,24 @@ static struct ip6_tnl *ip6_tnl_create(struct ip6_tnl_parm *p) ...@@ -238,17 +238,24 @@ static struct ip6_tnl *ip6_tnl_create(struct ip6_tnl_parm *p)
if (dev == NULL) if (dev == NULL)
goto failed; goto failed;
if (strchr(name, '%')) {
if (dev_alloc_name(dev, name) < 0)
goto failed_free;
}
t = netdev_priv(dev); t = netdev_priv(dev);
dev->init = ip6_tnl_dev_init; dev->init = ip6_tnl_dev_init;
t->parms = *p; t->parms = *p;
if ((err = register_netdevice(dev)) < 0) { if ((err = register_netdevice(dev)) < 0)
free_netdev(dev); goto failed_free;
goto failed;
}
dev_hold(dev); dev_hold(dev);
ip6_tnl_link(t); ip6_tnl_link(t);
return t; return t;
failed_free:
free_netdev(dev);
failed: failed:
return NULL; return NULL;
} }
......
...@@ -171,6 +171,11 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int ...@@ -171,6 +171,11 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int
if (dev == NULL) if (dev == NULL)
return NULL; return NULL;
if (strchr(name, '%')) {
if (dev_alloc_name(dev, name) < 0)
goto failed_free;
}
nt = netdev_priv(dev); nt = netdev_priv(dev);
dev->init = ipip6_tunnel_init; dev->init = ipip6_tunnel_init;
nt->parms = *parms; nt->parms = *parms;
...@@ -178,16 +183,16 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int ...@@ -178,16 +183,16 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int
if (parms->i_flags & SIT_ISATAP) if (parms->i_flags & SIT_ISATAP)
dev->priv_flags |= IFF_ISATAP; dev->priv_flags |= IFF_ISATAP;
if (register_netdevice(dev) < 0) { if (register_netdevice(dev) < 0)
free_netdev(dev); goto failed_free;
goto failed;
}
dev_hold(dev); dev_hold(dev);
ipip6_tunnel_link(nt); ipip6_tunnel_link(nt);
return nt; return nt;
failed_free:
free_netdev(dev);
failed: failed:
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment