Skip to content

Commit

Permalink
KVM: x86: disallow KVM_{SET,GET}_LAPIC without allocated in-kernel lapic
Browse files Browse the repository at this point in the history
Otherwise kvm might attempt to dereference a NULL pointer.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
  • Loading branch information
matosatti authored and avikivity committed Dec 3, 2009
1 parent 3ddea12 commit 2204ae3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,9 @@ long kvm_arch_vcpu_ioctl(struct file *filp,

switch (ioctl) {
case KVM_GET_LAPIC: {
r = -EINVAL;
if (!vcpu->arch.apic)
goto out;
lapic = kzalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL);

r = -ENOMEM;
Expand All @@ -1908,6 +1911,9 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
break;
}
case KVM_SET_LAPIC: {
r = -EINVAL;
if (!vcpu->arch.apic)
goto out;
lapic = kmalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL);
r = -ENOMEM;
if (!lapic)
Expand Down

0 comments on commit 2204ae3

Please sign in to comment.