From: Nicolas Dichtel Date: Thu, 29 Nov 2018 13:45:39 +0000 (+0100) Subject: tun: forbid iface creation with rtnl ops X-Git-Tag: v3.18.130~34 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eb75b9b7ec77ed5d11316ef99ee905a16b432430;p=profile%2Fwearable%2Fplatform%2Fkernel%2Flinux-3.18-exynos7270.git tun: forbid iface creation with rtnl ops [ Upstream commit 35b827b6d06199841a83839e8bb69c0cd13a28be ] 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: f019a7a594d9 ("tun: Implement ip link del tunXXX") CC: Eric W. Biederman Signed-off-by: Nicolas Dichtel Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 7448ebe..6338be5 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1423,9 +1423,9 @@ static void tun_setup(struct net_device *dev) */ static int tun_validate(struct nlattr *tb[], struct nlattr *data[]) { - if (!data) - return 0; - return -EINVAL; + /* NL_SET_ERR_MSG(extack, + "tun/tap creation via rtnetlink is not supported."); */ + return -EOPNOTSUPP; } static struct rtnl_link_ops tun_link_ops __read_mostly = {