All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Andrew Honig <ahonig@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: Memory leak in vmx.c
Date: Sat, 08 Dec 2012 09:31:04 +0100	[thread overview]
Message-ID: <50C2FAC8.2070303@web.de> (raw)
In-Reply-To: <CAKB9nXvMuGZ5Jrci1dE9K1+vWRdMrm_tLekM59X8b3hLmWFTiQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1250 bytes --]

On 2012-12-07 20:51, Andrew Honig wrote:
> 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.

Both pages are per-vm. Therefore they are freed in kvm_arch_destroy_vm.
But I have to admit that I dug a while as well to find this out.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 261 bytes --]

  reply	other threads:[~2012-12-08  8:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-07 19:51 Memory leak in vmx.c Andrew Honig
2012-12-08  8:31 ` Jan Kiszka [this message]
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=50C2FAC8.2070303@web.de \
    --to=jan.kiszka@web.de \
    --cc=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.