- patches.fixes/kvm-set-irq.patch: KVM: Fix buffer overflow in
[opensuse:kernel-source.git] / patches.fixes / kvm-set-irq.patch
1 From f2ebd422f71cda9c791f76f85d2ca102ae34a1ed Mon Sep 17 00:00:00 2001
2 From: Avi Kivity <avi@redhat.com>
3 Date: Sun, 22 Apr 2012 17:02:11 +0300
4 Subject: [PATCH] KVM: Fix buffer overflow in kvm_set_irq()
5 References: bnc#767612 CVE-2012-2137
6 Patch-Mainline: v3.5
7 Git-commit: f2ebd422f71cda9c791f76f85d2ca102ae34a1ed
8
9 kvm_set_irq() has an internal buffer of three irq routing entries, allowing
10 connecting a GSI to three IRQ chips or on MSI.  However setup_routing_entry()
11 does not properly enforce this, allowing three irqchip routes followed by
12 an MSI route to overflow the buffer.
13
14 Fix by ensuring that an MSI entry is added to an empty list.
15
16 Signed-off-by: Avi Kivity <avi@redhat.com>
17 Acked-by: Alexander Graf <agraf@suse.de>
18
19 diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
20 index a6a0365..5afb431 100644
21 --- a/virt/kvm/irq_comm.c
22 +++ b/virt/kvm/irq_comm.c
23 @@ -332,6 +332,7 @@ static int setup_routing_entry(struct kvm_irq_routing_table *rt,
24          */
25         hlist_for_each_entry(ei, n, &rt->map[ue->gsi], link)
26                 if (ei->type == KVM_IRQ_ROUTING_MSI ||
27 +                   ue->type == KVM_IRQ_ROUTING_MSI ||
28                     ue->u.irqchip.irqchip == ei->irqchip.irqchip)
29                         return r;
30