kni: guard against unterminated name oops
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>
Tue, 13 Dec 2016 01:08:19 +0000 (02:08 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Sun, 29 Jan 2017 21:50:28 +0000 (22:50 +0100)
If the name is too long, it triggers BUG in alloc_netdev().

Signed-off-by: Michał Mirosław <michal.miroslaw@atendesoftware.pl>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
lib/librte_eal/linuxapp/kni/kni_misc.c

index 03dacc1..33b61f2 100644 (file)
@@ -343,6 +343,12 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num,
                return -EIO;
        }
 
                return -EIO;
        }
 
+       /* Check if name is zero-ended */
+       if (strnlen(dev_info.name, sizeof(dev_info.name)) == sizeof(dev_info.name)) {
+               pr_err("kni.name not zero-terminated");
+               return -EINVAL;
+       }
+
        /**
         * Check if the cpu core id is valid for binding.
         */
        /**
         * Check if the cpu core id is valid for binding.
         */