nfct: Fix use-after-free / double-free
PATCH 1/1 nfct: Fix use-after-free / double-free
helper's list and flush commands handlers shouldn't call mnl_socket_close on the passed netlink socket as it is done in the main function after parse_params call.
---
(gdb) run helper list
Starting program: /usr/local/sbin/nfct helper list
*** glibc detected *** /usr/local/sbin/nfct: double free or corruption (fasttop): 0x0000000000606010 *** [...]
(gdb) bt
#0 0x00007ffff723e425 in __GI_raise (sig=<optimized out>)
at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x00007ffff7241b8b in __GI_abort () at abort.c:91
#2 0x00007ffff727c39e in __libc_message (do_abort=2,
fmt=0x7ffff7386028 "*** glibc detected *** %s: %s: 0x%s ***\n")
at ../sysdeps/unix/sysv/linux/libc_fatal.c:201
#3 0x00007ffff7286b96 in malloc_printerr (action=3,
str=0x7ffff7386218 "double free or corruption (fasttop)", ptr=<optimized out>) at malloc.c:5018#4 0x00007ffff7bd5e82 in mnl_socket_close (nl=nl@entry=0x606010) at socket.c:249 #5 0x0000000000401a74 in main (argc=3, argv=0x7fffffffe6d8) at nfct.c:115
src/nfct-extensions/helper.c +0 -4
@@ -144,8 +144,6 @@ static int nfct_cmd_helper_list(struct mnl_socket *nl, int argc, char *argv[])return -1 ; } -mnl_socket_close (nl); -return 0 ; }
@@ -397,8 +395,6 @@ nfct_cmd_helper_flush(struct mnl_socket *nl, int argc, char *argv[])return -1 ; } -mnl_socket_close (nl); -return 0 ; }
Quoted 3 lines · Hani Benhabiles
helper's list and flush commands handlers shouldn't call
mnl_socket_closeon the passed netlink socket as it is done in the main function afterparse_paramscall.
Applied, thanks Hani.