drakvuf
drakvuf copied to clipboard
Memory leaks in usermode hook callbacks
Various plugins using usermode hooks fail to properly track track their memory allocations and free them when DRAKVUF is interrupted. All plugins need to track their memory allocations such that if the plugin is interrupted at any point in time the plugin's destructor can properly clean up.
Plugins not currently doing that: apimon & rpcmon
cc: @skvl @sasza8 @icedevml
=================================================================
==154421==ERROR: LeakSanitizer: detected memory leaks
Indirect leak of 96 byte(s) in 1 object(s) allocated from:
#0 0x5237ad in operator new(unsigned long, std::nothrow_t const&) (/shared/jenkins/workspace/DRAKVUF-windows7-sp1-x64/src/drakvuf+0x5237ad)
#1 0xb4d830 in usermode_hook_cb(drakvuf*, drakvuf_trap_info*) (/shared/jenkins/workspace/DRAKVUF-windows7-sp1-x64/src/drakvuf+0xb4d830)
#2 0x56d738 in int3_cb (/shared/jenkins/workspace/DRAKVUF-windows7-sp1-x64/src/drakvuf+0x56d738)
#3 0x7fe2b3b86924 in process_software_breakpoint /shared/libvmi/libvmi/driver/xen/xen_events.c:697:5
Indirect leak of 96 byte(s) in 1 object(s) allocated from:
#0 0x5237ad in operator new(unsigned long, std::nothrow_t const&) (/shared/jenkins/workspace/DRAKVUF-windows7-sp1-x64/src/drakvuf+0x5237ad)
#1 0xb4d014 in usermode_hook_cb(drakvuf*, drakvuf_trap_info*) (/shared/jenkins/workspace/DRAKVUF-windows7-sp1-x64/src/drakvuf+0xb4d014)
#2 0x56d738 in int3_cb (/shared/jenkins/workspace/DRAKVUF-windows7-sp1-x64/src/drakvuf+0x56d738)
#3 0x7fe2b3b86924 in process_software_breakpoint /shared/libvmi/libvmi/driver/xen/xen_events.c:697:5
Indirect leak of 16 byte(s) in 1 object(s) allocated from:
#0 0x52358d in operator new(unsigned long) (/shared/jenkins/workspace/DRAKVUF-windows7-sp1-x64/src/drakvuf+0x52358d)
#1 0x692f69 in __gnu_cxx::new_allocator<unsigned long>::allocate(unsigned long, void const*) (/shared/jenkins/workspace/DRAKVUF-windows7-sp1-x64/src/drakvuf+0x692f69)
#2 0x692ecd in std::allocator_traits<std::allocator<unsigned long> >::allocate(std::allocator<unsigned long>&, unsigned long) (/shared/jenkins/workspace/DRAKVUF-windows7-sp1-x64/src/drakvuf+0x692ecd)
#3 0x692673 in std::_Vector_base<unsigned long, std::allocator<unsigned long> >::_M_allocate(unsigned long) (/shared/jenkins/workspace/DRAKVUF-windows7-sp1-x64/src/drakvuf+0x692673)
#4 0x690f92 in void std::vector<unsigned long, std::allocator<unsigned long> >::_M_realloc_insert<unsigned long const&>(__gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, unsigned long const&) (/shared/jenkins/workspace/DRAKVUF-windows7-sp1-x64/src/drakvuf+0x690f92)
#5 0x69069b in std::vector<unsigned long, std::allocator<unsigned long> >::push_back(unsigned long const&) (/shared/jenkins/workspace/DRAKVUF-windows7-sp1-x64/src/drakvuf+0x69069b)
#6 0xb4db7c in usermode_hook_cb(drakvuf*, drakvuf_trap_info*) (/shared/jenkins/workspace/DRAKVUF-windows7-sp1-x64/src/drakvuf+0xb4db7c)
#7 0x56d738 in int3_cb (/shared/jenkins/workspace/DRAKVUF-windows7-sp1-x64/src/drakvuf+0x56d738)
#8 0x7fe2b3b86924 in process_software_breakpoint /shared/libvmi/libvmi/driver/xen/xen_events.c:697:5
SUMMARY: AddressSanitizer: 208 byte(s) leaked in 3 allocation(s).
How to reproduce: compile DRAKVUF with --enable-sanitize
and run with default settings on a Win7 SP1 x64 VM. Error triggers reproducibly on the Jenkins CI.