KVM: arm/arm64: vgic: Prevent access to invalid SPIs
commiteb13abb0e515598f7be1692e5940ba16f62304f8
authorAndre Przywara <andre.przywara@arm.com>
Tue, 1 Nov 2016 18:00:08 +0000 (1 18:00 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 18 Nov 2016 09:51:48 +0000 (18 10:51 +0100)
tree4f901d2cb43ea2bc71a775fd1eebc50c2d1ecc5e
parent2850fad5acb02d58e45bf7cab169418aab8c51f4
KVM: arm/arm64: vgic: Prevent access to invalid SPIs

commit 112b0b8f8f6e18d4695d21457961c0e1b322a1d7 upstream.

In our VGIC implementation we limit the number of SPIs to a number
that the userland application told us. Accordingly we limit the
allocation of memory for virtual IRQs to that number.
However in our MMIO dispatcher we didn't check if we ever access an
IRQ beyond that limit, leading to out-of-bound accesses.
Add a test against the number of allocated SPIs in check_region().
Adjust the VGIC_ADDR_TO_INT macro to avoid an actual division, which
is not implemented on ARM(32).

[maz: cleaned-up original patch]

Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
virt/kvm/arm/vgic/vgic-mmio.c
virt/kvm/arm/vgic/vgic-mmio.h