[dpdk-dev] [PATCH 0/1] kni: fix segfault in rte_kni_get

Dan Gora dg at adax.com
Fri Jun 29 00:57:45 CEST 2018


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
<snip>
(gdb) run
<snip>
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 at 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=<optimized out>, data=<optimized out>) at commands.c:75
\#4  0x00000000005d829d in cmdline_parse (cl=cl at 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=<optimized out>, buf=<optimized out>, size=<optimized out>) at /home/dg/dpdk/latest/lib/librte_cmdline/cmdline.c:31
\#6  0x00000000005da154 in rdline_char_in (rdl=rdl at entry=0x7699260, c=10 '\n') at /home/dg/dpdk/latest/lib/librte_cmdline/cmdline_rdline.c:421
\#7  0x00000000005d6f5c in cmdline_in (cl=cl at entry=0x7699250, buf=buf at 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 at entry=0x7699250) at /home/dg/dpdk/latest/lib/librte_cmdline/cmdline.c:251
\#9  0x0000000000460ddd in main (argc=<optimized out>, argv=<optimized out>) at test.c:130
(gdb) up
\#1  0x00000000005e481e in rte_kni_get (name=name at 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' <repeats 18 times>
(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



More information about the dev mailing list