Commit a93ceff4 authored by Nicolas Dichtel's avatar Nicolas Dichtel Committed by Juerg Haefliger

tun: forbid iface creation with rtnl ops

BugLink: https://bugs.launchpad.net/bugs/1811080

[ Upstream commit 35b827b6 ]

It's not supported right now (the goal of the initial patch was to support
'ip link del' only).

Before the patch:
$ ip link add foo type tun
[  239.632660] BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
[snip]
[  239.636410] RIP: 0010:register_netdevice+0x8e/0x3a0

This panic occurs because dev->netdev_ops is not set by tun_setup(). But to
have something usable, it will require more than just setting
netdev_ops.

Fixes: f019a7a5 ("tun: Implement ip link del tunXXX")
CC: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent 947b666b
...@@ -1475,9 +1475,9 @@ static void tun_setup(struct net_device *dev) ...@@ -1475,9 +1475,9 @@ static void tun_setup(struct net_device *dev)
*/ */
static int tun_validate(struct nlattr *tb[], struct nlattr *data[]) static int tun_validate(struct nlattr *tb[], struct nlattr *data[])
{ {
if (!data) /* NL_SET_ERR_MSG(extack,
return 0; "tun/tap creation via rtnetlink is not supported."); */
return -EINVAL; return -EOPNOTSUPP;
} }
static struct rtnl_link_ops tun_link_ops __read_mostly = { static struct rtnl_link_ops tun_link_ops __read_mostly = {
......
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