Skip to content

Commit 3a8b067

Browse files
schnhrrbonzini
authored andcommitted
KVM: VMX: Do not BUG() on out-of-bounds guest IRQ
The value of the guest_irq argument to vmx_update_pi_irte() is ultimately coming from a KVM_IRQFD API call. Do not BUG() in vmx_update_pi_irte() if the value is out-of bounds. (Especially, since KVM as a whole seems to hang after that.) Instead, print a message only once if we find that we don't have a route for a certain IRQ (which can be out-of-bounds or within the array). This fixes CVE-2017-1000252. Fixes: efc6440 ("KVM: x86: Update IRTE for posted-interrupts") Signed-off-by: Jan H. Schönherr <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 36ae3c0 commit 3a8b067

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

arch/x86/kvm/vmx.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11834,7 +11834,7 @@ static int vmx_update_pi_irte(struct kvm *kvm, unsigned int host_irq,
1183411834
struct kvm_lapic_irq irq;
1183511835
struct kvm_vcpu *vcpu;
1183611836
struct vcpu_data vcpu_info;
11837-
int idx, ret = -EINVAL;
11837+
int idx, ret = 0;
1183811838

1183911839
if (!kvm_arch_has_assigned_device(kvm) ||
1184011840
!irq_remapping_cap(IRQ_POSTING_CAP) ||
@@ -11843,7 +11843,12 @@ static int vmx_update_pi_irte(struct kvm *kvm, unsigned int host_irq,
1184311843

1184411844
idx = srcu_read_lock(&kvm->irq_srcu);
1184511845
irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu);
11846-
BUG_ON(guest_irq >= irq_rt->nr_rt_entries);
11846+
if (guest_irq >= irq_rt->nr_rt_entries ||
11847+
hlist_empty(&irq_rt->map[guest_irq])) {
11848+
pr_warn_once("no route for guest_irq %u/%u (broken user space?)\n",
11849+
guest_irq, irq_rt->nr_rt_entries);
11850+
goto out;
11851+
}
1184711852

1184811853
hlist_for_each_entry(e, &irq_rt->map[guest_irq], link) {
1184911854
if (e->type != KVM_IRQ_ROUTING_MSI)

0 commit comments

Comments
 (0)