net: check extack._msg before print
authorLi RongQing <lirongqing@baidu.com>
Fri, 3 Aug 2018 07:45:21 +0000 (15:45 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 6 Aug 2018 00:24:45 +0000 (17:24 -0700)
dev_set_mtu_ext is able to fail with a valid mtu value, at that
condition, extack._msg is not set and random since it is in stack,
then kernel will crash when print it.

Fixes: 7a4c53bee3324a ("net: report invalid mtu value via netlink extack")
Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/dev.c

index 36e9945..f68122f 100644 (file)
@@ -7583,8 +7583,9 @@ int dev_set_mtu(struct net_device *dev, int new_mtu)
        struct netlink_ext_ack extack;
        int err;
 
+       memset(&extack, 0, sizeof(extack));
        err = dev_set_mtu_ext(dev, new_mtu, &extack);
-       if (err)
+       if (err && extack._msg)
                net_err_ratelimited("%s: %s\n", dev->name, extack._msg);
        return err;
 }