Skip to contentSkip to conversation

KVM: arm/arm64: Stop leaking vcpu pid references

PATCH Applied James Morse 2 participants 2 messages Jun 8, 2016 – Jun 27, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: arm/arm64: Stop leaking vcpu pid references

kvm provides kvm_vcpu_uninit(), which amongst other things, releases the last reference to the struct pid of the task that was last running the vcpu.

On arm64 built with CONFIG_DEBUG_KMEMLEAK, starting a guest with kvmtool, then killing it with SIGKILL results (after some considerable time) in:

Quoted 4 lines

cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff80007d5ea080 (size 128):
comm "lkvm", pid 2025, jiffies 4294942645 (age 1107.776s) hex dump (first 32 bytes):

Quoted 12 lines
   01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 backtrace:
   [<ffff8000001b30ec>] create_object+0xfc/0x278
   [<ffff80000071da34>] kmemleak_alloc+0x34/0x70
   [<ffff80000019fa2c>] kmem_cache_alloc+0x16c/0x1d8
   [<ffff8000000d0474>] alloc_pid+0x34/0x4d0
   [<ffff8000000b5674>] copy_process.isra.6+0x79c/0x1338
   [<ffff8000000b633c>] _do_fork+0x74/0x320
   [<ffff8000000b66b0>] SyS_clone+0x18/0x20
   [<ffff800000085cb0>] el0_svc_naked+0x24/0x28
   [<ffffffffffffffff>] 0xffffffffffffffff

On x86 kvm_vcpu_uninit() is called on the path from kvm_arch_destroy_vm(), on arm no equivalent call is made. Add the call to kvm_arch_vcpu_free().

Fixes 749cf76c5a36 ("KVM: ARM: Initial skeleton to compile KVM support")
Cc <[email protected]> # 3.10+
---
 arch/arm/kvm/arm.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm/kvm/arm.c +1 -0
index 893941ec98dc..f1bde7c4e736 100644
@@ -263,6 +263,7 @@ void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
 	kvm_timer_vcpu_terminate(vcpu);
 	kvm_vgic_vcpu_destroy(vcpu);
 	kvm_pmu_vcpu_destroy(vcpu);
+	kvm_vcpu_uninit(vcpu);
 	kmem_cache_free(kvm_vcpu_cache, vcpu);
 }
 
Signature · 1 line
2.8.0.rc3
#1 lore raw
Quoted 22 lines · James Morse

kvm provides kvm_vcpu_uninit(), which amongst other things, releases the last reference to the struct pid of the task that was last running the vcpu.

On arm64 built with CONFIG_DEBUG_KMEMLEAK, starting a guest with kvmtool, then killing it with SIGKILL results (after some considerable time) in:

Quoted 4 lines

cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff80007d5ea080 (size 128):
comm "lkvm", pid 2025, jiffies 4294942645 (age 1107.776s) hex dump (first 32 bytes):

Quoted 12 lines
   01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 backtrace:
   [<ffff8000001b30ec>] create_object+0xfc/0x278
   [<ffff80000071da34>] kmemleak_alloc+0x34/0x70
   [<ffff80000019fa2c>] kmem_cache_alloc+0x16c/0x1d8
   [<ffff8000000d0474>] alloc_pid+0x34/0x4d0
   [<ffff8000000b5674>] copy_process.isra.6+0x79c/0x1338
   [<ffff8000000b633c>] _do_fork+0x74/0x320
   [<ffff8000000b66b0>] SyS_clone+0x18/0x20
   [<ffff800000085cb0>] el0_svc_naked+0x24/0x28
   [<ffffffffffffffff>] 0xffffffffffffffff
Quoted 7 lines

On x86 kvm_vcpu_uninit() is called on the path from kvm_arch_destroy_vm(), on arm no equivalent call is made. Add the call to kvm_arch_vcpu_free().

Fixes 749cf76c5a36 ("KVM: ARM: Initial skeleton to compile KVM support")
Cc <[email protected]> # 3.10+

Applied, thanks.

-Christoffer