From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: Memory leak in vmx.c Date: Sat, 08 Dec 2012 09:31:04 +0100 Message-ID: <50C2FAC8.2070303@web.de> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig168FECA02F42F79BF8B2CF90" Cc: kvm@vger.kernel.org To: Andrew Honig Return-path: Received: from mout.web.de ([212.227.15.3]:62991 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751472Ab2LHIbL (ORCPT ); Sat, 8 Dec 2012 03:31:11 -0500 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig168FECA02F42F79BF8B2CF90 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2012-12-07 20:51, Andrew Honig wrote: > I've noticed a memory leak that occurs in vmx.c. >=20 > 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. >=20 > 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. >=20 > 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 --------------enig168FECA02F42F79BF8B2CF90 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with undefined - http://www.enigmail.net/ iEYEARECAAYFAlDC+swACgkQitSsb3rl5xTyzACfS3tt2eMavQEluNrhRC8uXEyn /9AAoLBxzgqXForhKgwEBRWtw06i9iDL =yyE3 -----END PGP SIGNATURE----- --------------enig168FECA02F42F79BF8B2CF90--