-
Notifications
You must be signed in to change notification settings - Fork 923
Closed as not planned
Description
Hi,
when fuzzing the libpcap, I found pcap_create could be easily crashed when passing it with a NULL errbuf.
Your documentation in pcap_create haven't said that the errbuf cannot be a NULL pointer.
So I just assume that if no custom error buf is provided, the error message will be delivered to stderr or other places.
However, after I fuzzed the pcap_create("eth0", nullptr) for some rounds until some operations could cause the pcap_create failed, the pcap_create will crash if it was passed with NULL errbuf.
My environment:
CentOS 5.4
The PoC program is like that:
extern "C" int LLVMFuzzerTestOneInput_4(const uint8_t* data, size_t size) {
pcap_t *handle = pcap_create("eth0", nullptr);
...//some operations to change the environment
pcap_close(handle);
return 0;
}
==707630==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fc9bb8d0f81 bp 0x000000000000 sp 0x7ffeeb206180 T0)
==707630==The signal is caused by a WRITE memory access.
==707630==Hint: address points to the zero page.
#0 0x7fc9bb8d0f81 (/lib/x86_64-linux-gnu/libc.so.6+0x8bf81) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
#1 0x55c4d98bcb1a in vsnprintf /work/llvm/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:1746:1
#2 0x55c4d9a8037c in pcapint_vfmt_errmsg_for_errno /libpcap/src/libpcap/fmtutils.c:287:8
#3 0x55c4d9a8020f in pcapint_fmt_errmsg_for_errno /libpcap/src/libpcap/fmtutils.c:275:2
#4 0x55c4d9a23e6a in iface_get_ts_types /libpcap/src/libpcap/pcap-linux.c
#5 0x55c4d9a23e6a in pcapint_create_interface /libpcap/src/libpcap/pcap-linux.c:354:6
#6 0x55c4d99fcffc in pcap_create /libpcap/src/libpcap/pcap.c:2412:6
#7 0x55c4d9969cf1 in LLVMFuzzerTestOneInput_4 /id_000004.cc:62:22
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels