From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: [patch 2/3] KVM: x86: disallow KVM_{SET,GET}_LAPIC without in kernel irqchip Date: Tue, 27 Oct 2009 13:10:44 -0200 Message-ID: <20091027151125.345664553@redhat.com> References: <20091027151042.118902183@redhat.com> Cc: kvm , stable@kernel.org, Marcelo Tosatti To: avi@redhat.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:8583 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753741AbZJ0POU (ORCPT ); Tue, 27 Oct 2009 11:14:20 -0400 Content-Disposition: inline; filename=get-set-lapic Sender: kvm-owner@vger.kernel.org List-ID: Otherwise kvm might attempt to dereference a NULL pointer. CC: stable@kernel.org Signed-off-by: Marcelo Tosatti Index: kvm/arch/x86/kvm/x86.c =================================================================== --- kvm.orig/arch/x86/kvm/x86.c +++ kvm/arch/x86/kvm/x86.c @@ -1815,6 +1815,9 @@ long kvm_arch_vcpu_ioctl(struct file *fi switch (ioctl) { case KVM_GET_LAPIC: { + r = -EINVAL; + if (!irqchip_in_kernel(vcpu->kvm)) + goto out; lapic = kzalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL); r = -ENOMEM; @@ -1830,6 +1833,9 @@ long kvm_arch_vcpu_ioctl(struct file *fi break; } case KVM_SET_LAPIC: { + r = -EINVAL; + if (!irqchip_in_kernel(vcpu->kvm)) + goto out; lapic = kmalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL); r = -ENOMEM; if (!lapic)