kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Memory leak in vmx.c
@ 2012-12-07 19:51 Andrew Honig
  2012-12-08  8:31 ` Jan Kiszka
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Honig @ 2012-12-07 19:51 UTC (permalink / raw)
  To: kvm

I've noticed a memory leak that occurs in vmx.c.

In alloc_apic_access_page, it calls __kvm_set_memory_region(kvm,
&kvm_userspace_mem, 0).  __kvm_set_memory_region calls
kvm_arch_prepare_memory_region, which because the user_alloc parameter
is 0 will allocate memory for the page with vm_mmap.

This memory never gets freed.   In kvm_arch_destroy_vm it calls
put_page(kvm->arch.apic_access_page), but that only unpins the memory
(necessary due to an earlier call to gfn_to_page), it never actually
frees the memory.  The memory is allocated in the current process
context so it's cleaned up when the process exits, but if a process
creates and destroys multiple VMs then this leak starts to become a
problem.

Similar leaks occur in alloc_identity_pagetable and vmx_set_tss_addr
for a total of 5 pages of memory leak for a VM.  The vmx_set_tss_addr
actually leaks each time vmx_set_tss_addr is called so this could also
become a problem if a program had occasion to set the tss addr several
times.

thanks,
Andy

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-12-15 10:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-07 19:51 Memory leak in vmx.c Andrew Honig
2012-12-08  8:31 ` Jan Kiszka
2012-12-10 18:36   ` Andrew Honig
2012-12-15 10:09     ` Jan Kiszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).