Skip to contentSkip to conversation

Fix qemu crash with kvm enabled.

PATCH RESEND In review Gerd Hoffmann 2 participants 3 messages Dec 15, 2008 – Dec 16, 2008

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 Fix qemu crash with kvm enabled.

Hi,

If you see crashes after commit 6060, try this one ;)

Not initializing msr_list.nmsrs before the KVM_GET_MSR_INDEX_LIST ioctl will make the kernel fill too much data into msr_list, thereby overflowing the stack and crashing the qemu.

cheers,
Gerd

Quoted 1 line

From cb6c5b6fde117fe05699230c43c3163e91dbb3cd Mon Sep 17 00:00:00 2001

From: Gerd Hoffmann <[email protected]>
Date: Tue, 9 Dec 2008 17:42:27 +0100
Subject: [PATCH] Fix qemu crash with kvm enabled.

---
 target-i386/kvm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
target-i386/kvm.c +1 -1
index effd5af..db11ac2 100644
@@ -104,11 +104,11 @@ static int kvm_has_msr_star(CPUState *env)
 
         /* Obtain MSR list from KVM.  These are the MSRs that we must
          * save/restore */
+        msr_list.nmsrs = 0;
         ret = kvm_ioctl(env->kvm_state, KVM_GET_MSR_INDEX_LIST, &msr_list);
         if (ret < 0)
             return 0;
 
-        msr_list.nmsrs = 0;
         kvm_msr_list = qemu_mallocz(sizeof(msr_list) +
                                     msr_list.nmsrs * sizeof(msr_list.indices[0]));
         if (kvm_msr_list == NULL)
Signature · 1 line
1.5.6.5
#1 lore raw
Quoted 8 lines · Gerd Hoffmann

Hi,

If you see crashes after commit 6060, try this one ;)

Not initializing msr_list.nmsrs before the KVM_GET_MSR_INDEX_LIST ioctl will make the kernel fill too much data into msr_list, thereby overflowing the stack and crashing the qemu.

I've applied that. Or at least I thoguht I did.

Regards,

Anthony Liguori

Quoted 3 lines

cheers,
Gerd

#2 lore raw
Quoted 10 lines · Anthony Liguori
Quoted 7 lines · Gerd Hoffmann

Hi,

If you see crashes after commit 6060, try this one ;)

Not initializing msr_list.nmsrs before the KVM_GET_MSR_INDEX_LIST ioctl will make the kernel fill too much data into msr_list, thereby overflowing the stack and crashing the qemu.

I've applied that. Or at least I thoguht I did.

Yes, is in, I somehow missed the commit message.

thanks,
Gerd