Explorar o código

KVM: Fix buffer overflow in kvm_set_irq()

kvm_set_irq() has an internal buffer of three irq routing entries, allowing
connecting a GSI to three IRQ chips or on MSI.  However setup_routing_entry()
does not properly enforce this, allowing three irqchip routes followed by
an MSI route to overflow the buffer.

Fix by ensuring that an MSI entry is added to an empty list.

Signed-off-by: Avi Kivity <avi@redhat.com>
Avi Kivity %!s(int64=13) %!d(string=hai) anos
pai
achega
f2ebd422f7
Modificáronse 1 ficheiros con 1 adicións e 0 borrados
  1. 1 0
      virt/kvm/irq_comm.c

+ 1 - 0
virt/kvm/irq_comm.c

@@ -332,6 +332,7 @@ static int setup_routing_entry(struct kvm_irq_routing_table *rt,
 	 */
 	hlist_for_each_entry(ei, n, &rt->map[ue->gsi], link)
 		if (ei->type == KVM_IRQ_ROUTING_MSI ||
+		    ue->type == KVM_IRQ_ROUTING_MSI ||
 		    ue->u.irqchip.irqchip == ei->irqchip.irqchip)
 			return r;