summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorCong Wang <xiyou.wangcong@gmail.com>2017-10-13 21:58:53 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-11-18 13:30:36 +0300
commitaa9ab97c4d79b29727344f9c77d673743bbe35cb (patch)
tree0d75aa2ed628abcf164afae339d270699cbb27c3 /drivers
parent4531b5b14d4104e70ae2ed1608e5373992bb6f14 (diff)
downloadlinux-aa9ab97c4d79b29727344f9c77d673743bbe35cb.tar.xz
tun: call dev_get_valid_name() before register_netdevice()
[ Upstream commit 0ad646c81b2182f7fa67ec0c8c825e0ee165696d ] register_netdevice() could fail early when we have an invalid dev name, in which case ->ndo_uninit() is not called. For tun device, this is a problem because a timer etc. are already initialized and it expects ->ndo_uninit() to clean them up. We could move these initializations into a ->ndo_init() so that register_netdevice() knows better, however this is still complicated due to the logic in tun_detach(). Therefore, I choose to just call dev_get_valid_name() before register_netdevice(), which is quicker and much easier to audit. And for this specific case, it is already enough. Fixes: 96442e42429e ("tuntap: choose the txq based on rxq") Reported-by: Dmitry Alexeev <avekceeb@gmail.com> Cc: Jason Wang <jasowang@redhat.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/tun.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index cb1f7747adad..9e7b4e7d3f97 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1813,6 +1813,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
if (!dev)
return -ENOMEM;
+ err = dev_get_valid_name(net, dev, name);
+ if (err)
+ goto err_free_dev;
dev_net_set(dev, net);
dev->rtnl_link_ops = &tun_link_ops;