mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
KVM: x86: disallow KVM_{SET,GET}_LAPIC without allocated in-kernel lapic
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>
This commit is contained in:
parent
3ddea128ad
commit
2204ae3c96
1 changed files with 6 additions and 0 deletions
|
@ -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;
|
||||
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue