From d613f57dd02936bd916007d6506253b6bc31c684 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Miros=C5=82aw?= Date: Tue, 13 Dec 2016 02:08:19 +0100 Subject: [PATCH] kni: guard against unterminated name oops MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If the name is too long, it triggers BUG in alloc_netdev(). Signed-off-by: Michał Mirosław Acked-by: Ferruh Yigit --- lib/librte_eal/linuxapp/kni/kni_misc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c index 03dacc1f90..33b61f2a8c 100644 --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -343,6 +343,12 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num, 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. */ -- 2.20.1