Commit ec90b611 authored by Avi Kivity's avatar Avi Kivity Committed by Greg Kroah-Hartman

KVM: Fix buffer overflow in kvm_set_irq()

commit f2ebd422 upstream.

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: default avatarAvi Kivity <avi@redhat.com>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
Cc: Li Zefan <lizefan@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 230a0c3b
...@@ -318,6 +318,7 @@ static int setup_routing_entry(struct kvm_irq_routing_table *rt, ...@@ -318,6 +318,7 @@ static int setup_routing_entry(struct kvm_irq_routing_table *rt,
*/ */
hlist_for_each_entry(ei, n, &rt->map[ue->gsi], link) hlist_for_each_entry(ei, n, &rt->map[ue->gsi], link)
if (ei->type == KVM_IRQ_ROUTING_MSI || if (ei->type == KVM_IRQ_ROUTING_MSI ||
ue->type == KVM_IRQ_ROUTING_MSI ||
ue->u.irqchip.irqchip == ei->irqchip.irqchip) ue->u.irqchip.irqchip == ei->irqchip.irqchip)
return r; return r;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment