Commit 1ce60c24 authored by Marc Zyngier's avatar Marc Zyngier Committed by Kamal Mostafa

KVM: arm/arm64: vgic: Avoid injecting reserved IRQ numbers

commit 4839ddc2 upstream.

Commit fd1d0ddf (KVM: arm/arm64: check IRQ number on userland
injection) rightly limited the range of interrupts userspace can
inject in a guest, but failed to consider the (unlikely) case where
a guest is configured with 1024 interrupts.

In this case, interrupts ranging from 1020 to 1023 are unuseable,
as they have a special meaning for the GIC CPU interface.

Make sure that these number cannot be used as an IRQ. Also delete
a redundant (and similarily buggy) check in kvm_set_irq.
Reported-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Cc: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
[ kamal: backport to 3.19-stable: no change to kvm_set_irq ]
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent 27d102b1
...@@ -1722,7 +1722,7 @@ int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num, ...@@ -1722,7 +1722,7 @@ int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num,
goto out; goto out;
} }
if (irq_num >= kvm->arch.vgic.nr_irqs) if (irq_num >= min(kvm->arch.vgic.nr_irqs, 1020))
return -EINVAL; return -EINVAL;
vcpu_id = vgic_update_irq_pending(kvm, cpuid, irq_num, level); vcpu_id = vgic_update_irq_pending(kvm, cpuid, irq_num, level);
......
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