From: Andrew Honig <ahonig@google.com>
To: kvm@vger.kernel.org
Subject: Memory leak in vmx.c
Date: Fri, 7 Dec 2012 14:51:38 -0500 [thread overview]
Message-ID: <CAKB9nXvMuGZ5Jrci1dE9K1+vWRdMrm_tLekM59X8b3hLmWFTiQ@mail.gmail.com> (raw)
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
next reply other threads:[~2012-12-07 19:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-07 19:51 Andrew Honig [this message]
2012-12-08 8:31 ` Memory leak in vmx.c Jan Kiszka
2012-12-10 18:36 ` Andrew Honig
2012-12-15 10:09 ` Jan Kiszka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKB9nXvMuGZ5Jrci1dE9K1+vWRdMrm_tLekM59X8b3hLmWFTiQ@mail.gmail.com \
--to=ahonig@google.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).