aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2009-10-29 11:44:16 -0400
committerAvi Kivity <avi@redhat.com>2009-12-03 02:32:23 -0500
commit2204ae3c96e9a1fed50f7ee19ce092e69d7dfe82 (patch)
tree8cf0b2bb779c833b401b96e46c26f444ab70955d /arch/x86
parent3ddea128ad75bd33e88780fe44f44c3717369b98 (diff)
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>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kvm/x86.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 97f6f9565ac9..cd6fe0a5797f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1893,6 +1893,9 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
1893 1893
1894 switch (ioctl) { 1894 switch (ioctl) {
1895 case KVM_GET_LAPIC: { 1895 case KVM_GET_LAPIC: {
1896 r = -EINVAL;
1897 if (!vcpu->arch.apic)
1898 goto out;
1896 lapic = kzalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL); 1899 lapic = kzalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL);
1897 1900
1898 r = -ENOMEM; 1901 r = -ENOMEM;
@@ -1908,6 +1911,9 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
1908 break; 1911 break;
1909 } 1912 }
1910 case KVM_SET_LAPIC: { 1913 case KVM_SET_LAPIC: {
1914 r = -EINVAL;
1915 if (!vcpu->arch.apic)
1916 goto out;
1911 lapic = kmalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL); 1917 lapic = kmalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL);
1912 r = -ENOMEM; 1918 r = -ENOMEM;
1913 if (!lapic) 1919 if (!lapic)