From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Gora Subject: [PATCH 0/1] kni: fix segfault in rte_kni_get Date: Thu, 28 Jun 2018 15:57:45 -0700 Message-ID: <20180628225745.22629-1-dg@adax.com> Cc: dev@dpdk.org, Dan Gora Return-path: Received: from mail-ot0-f176.google.com (mail-ot0-f176.google.com [74.125.82.176]) by dpdk.org (Postfix) with ESMTP id 60D9C1B43B for ; Fri, 29 Jun 2018 00:58:09 +0200 (CEST) Received: by mail-ot0-f176.google.com with SMTP id h6-v6so7980155otj.0 for ; Thu, 28 Jun 2018 15:58:09 -0700 (PDT) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Fix a segmentation fault which occurs when the kni_autotest is run in the 'test' application. This segmenation fault occurs whe rte_kni_get is called with a NULL value for 'name'. Here is how the segfault was reproduced: [root]# insmod /home/dg/dpdk/latest/x86_64-native-linuxapp-gcc/build/kernel/linux/kni/rte_kni.ko lo_mode=lo_mode_fifo_skb [root]# gdb test (gdb) run RTE>>kni_autotest master lcore: 0 count: 2 KNI: pci: 04:00:00 8086:10fb Detaching after fork from child process 127900. KNI: Invalid KNI request operation. KNI: Invalid kni info. KNI: The KNI request operation has already registered. Detaching after fork from child process 127908. Change MTU of port 0 to 1450 Change MTU of port 0 to 1450 successfully. KNI: Invalid kni info. Detaching after fork from child process 127910. Detaching after fork from child process 127918. Detaching after fork from child process 127919. Detaching after fork from child process 127920. KNI: pci: 04:00:00 8086:10fb Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7017e00 in __strncmp_sse42 () from /lib64/libc.so.6 Missing separate debuginfos, use: debuginfo-install glibc-2.17-196.el7.x86_64 libgcc-4.8.5-16.el7.x86_64 numactl-libs-2.0.9-7.el7.x86_64 (gdb) bt \#0 0x00007ffff7017e00 in __strncmp_sse42 () from /lib64/libc.so.6 \#1 0x00000000005e481e in rte_kni_get (name=name@entry=0x0) at /home/dg/dpdk/latest/lib/librte_kni/rte_kni.c:753 \#2 0x00000000004dd13f in test_kni () at test_kni.c:638 \#3 0x000000000046630b in cmd_autotest_parsed (parsed_result=0x7fffffff7dc0, cl=, data=) at commands.c:75 \#4 0x00000000005d829d in cmdline_parse (cl=cl@entry=0x7699250, buf=0x7699298 "kni_autotest \n") at /home/dg/dpdk/latest/lib/librte_cmdline/cmdline_parse.c:295 \#5 0x00000000005d7240 in cmdline_valid_buffer (rdl=, buf=, size=) at /home/dg/dpdk/latest/lib/librte_cmdline/cmdline.c:31 \#6 0x00000000005da154 in rdline_char_in (rdl=rdl@entry=0x7699260, c=10 '\n') at /home/dg/dpdk/latest/lib/librte_cmdline/cmdline_rdline.c:421 \#7 0x00000000005d6f5c in cmdline_in (cl=cl@entry=0x7699250, buf=buf@entry=0x7fffffffdec0 "\n\003\034\177\025\004", size=1) at /home/dg/dpdk/latest/lib/librte_cmdline/cmdline.c:172 \#8 0x00000000005d74eb in cmdline_interact (cl=cl@entry=0x7699250) at /home/dg/dpdk/latest/lib/librte_cmdline/cmdline.c:251 \#9 0x0000000000460ddd in main (argc=, argv=) at test.c:130 (gdb) up \#1 0x00000000005e481e in rte_kni_get (name=name@entry=0x0) at /home/dg/dpdk/latest/lib/librte_kni/rte_kni.c:753 753 if (strncmp(kni->name, name, RTE_KNI_NAMESIZE) == 0) (gdb) l 748 for (i = 0; i < kni_memzone_pool.max_ifaces; i++) { 749 it = &kni_memzone_pool.slots[i]; 750 if (it->in_use == 0) 751 continue; 752 kni = it->m_ctx->addr; 753 if (strncmp(kni->name, name, RTE_KNI_NAMESIZE) == 0) 754 return kni; 755 } 756 757 return NULL; (gdb) info args name = 0x0 (gdb) print kni $1 = (struct rte_kni *) 0x7ff7ff904940 (gdb) print kni->name $2 = "test_kni_port", '\000' (gdb) Dan Gora (1): kni: fix segfault in rte_kni_get lib/librte_kni/rte_kni.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.18.0.rc1.1.g6f333ff2f