diff options
author | Marcelo Tosatti <mtosatti@redhat.com> | 2010-01-12 13:42:09 -0500 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2010-01-25 09:26:38 -0500 |
commit | d72118cecabbb76b96b77107a50c74d1bb36c0c1 (patch) | |
tree | bb000f670a2d60ddca4439723debd2321b1738ca /virt/kvm/irq_comm.c | |
parent | f1d1c309f35e9b0fb961cffd70fbd04f450ec47c (diff) |
KVM: properly check max PIC pin in irq route setup
Otherwise memory beyond irq_states[16] might be accessed.
Noticed by Juan Quintela.
Cc: stable@kernel.org
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm/irq_comm.c')
-rw-r--r-- | virt/kvm/irq_comm.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index 9b077342ab54..9fd5b3ebc517 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c | |||
@@ -302,6 +302,7 @@ static int setup_routing_entry(struct kvm_irq_routing_table *rt, | |||
302 | { | 302 | { |
303 | int r = -EINVAL; | 303 | int r = -EINVAL; |
304 | int delta; | 304 | int delta; |
305 | unsigned max_pin; | ||
305 | struct kvm_kernel_irq_routing_entry *ei; | 306 | struct kvm_kernel_irq_routing_entry *ei; |
306 | struct hlist_node *n; | 307 | struct hlist_node *n; |
307 | 308 | ||
@@ -322,12 +323,15 @@ static int setup_routing_entry(struct kvm_irq_routing_table *rt, | |||
322 | switch (ue->u.irqchip.irqchip) { | 323 | switch (ue->u.irqchip.irqchip) { |
323 | case KVM_IRQCHIP_PIC_MASTER: | 324 | case KVM_IRQCHIP_PIC_MASTER: |
324 | e->set = kvm_set_pic_irq; | 325 | e->set = kvm_set_pic_irq; |
326 | max_pin = 16; | ||
325 | break; | 327 | break; |
326 | case KVM_IRQCHIP_PIC_SLAVE: | 328 | case KVM_IRQCHIP_PIC_SLAVE: |
327 | e->set = kvm_set_pic_irq; | 329 | e->set = kvm_set_pic_irq; |
330 | max_pin = 16; | ||
328 | delta = 8; | 331 | delta = 8; |
329 | break; | 332 | break; |
330 | case KVM_IRQCHIP_IOAPIC: | 333 | case KVM_IRQCHIP_IOAPIC: |
334 | max_pin = KVM_IOAPIC_NUM_PINS; | ||
331 | e->set = kvm_set_ioapic_irq; | 335 | e->set = kvm_set_ioapic_irq; |
332 | break; | 336 | break; |
333 | default: | 337 | default: |
@@ -335,7 +339,7 @@ static int setup_routing_entry(struct kvm_irq_routing_table *rt, | |||
335 | } | 339 | } |
336 | e->irqchip.irqchip = ue->u.irqchip.irqchip; | 340 | e->irqchip.irqchip = ue->u.irqchip.irqchip; |
337 | e->irqchip.pin = ue->u.irqchip.pin + delta; | 341 | e->irqchip.pin = ue->u.irqchip.pin + delta; |
338 | if (e->irqchip.pin >= KVM_IOAPIC_NUM_PINS) | 342 | if (e->irqchip.pin >= max_pin) |
339 | goto out; | 343 | goto out; |
340 | rt->chip[ue->u.irqchip.irqchip][e->irqchip.pin] = ue->gsi; | 344 | rt->chip[ue->u.irqchip.irqchip][e->irqchip.pin] = ue->gsi; |
341 | break; | 345 | break; |