linux-stable/arch/arm64
Andre Przywara fd1d0ddf2a KVM: arm/arm64: check IRQ number on userland injection
When userland injects a SPI via the KVM_IRQ_LINE ioctl we currently
only check it against a fixed limit, which historically is set
to 127. With the new dynamic IRQ allocation the effective limit may
actually be smaller (64).
So when now a malicious or buggy userland injects a SPI in that
range, we spill over on our VGIC bitmaps and bytemaps memory.
I could trigger a host kernel NULL pointer dereference with current
mainline by injecting some bogus IRQ number from a hacked kvmtool:
-----------------
....
DEBUG: kvm_vgic_inject_irq(kvm, cpu=0, irq=114, level=1)
DEBUG: vgic_update_irq_pending(kvm, cpu=0, irq=114, level=1)
DEBUG: IRQ #114 still in the game, writing to bytemap now...
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = ffffffc07652e000
[00000000] *pgd=00000000f658b003, *pud=00000000f658b003, *pmd=0000000000000000
Internal error: Oops: 96000006 [#1] PREEMPT SMP
Modules linked in:
CPU: 1 PID: 1053 Comm: lkvm-msi-irqinj Not tainted 4.0.0-rc7+ #3027
Hardware name: FVP Base (DT)
task: ffffffc0774e9680 ti: ffffffc0765a8000 task.ti: ffffffc0765a8000
PC is at kvm_vgic_inject_irq+0x234/0x310
LR is at kvm_vgic_inject_irq+0x30c/0x310
pc : [<ffffffc0000ae0a8>] lr : [<ffffffc0000ae180>] pstate: 80000145
.....

So this patch fixes this by checking the SPI number against the
actual limit. Also we remove the former legacy hard limit of
127 in the ioctl code.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
CC: <stable@vger.kernel.org> # 4.0, 3.19, 3.18
[maz: wrap KVM_ARM_IRQ_GIC_MAX with #ifndef __KERNEL__,
as suggested by Christopher Covington]
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
2015-04-22 15:42:24 +01:00
..
boot arm64: juno: Fix misleading name of UART reference clock 2015-03-29 13:56:08 -07:00
configs ARM: SoC 64-bit changes and additions 2015-02-17 09:47:46 -08:00
crypto arm64: crypto: increase AES interleave to 4x 2015-02-26 18:31:46 +00:00
include KVM: arm/arm64: check IRQ number on userland injection 2015-04-22 15:42:24 +01:00
kernel Linux 4.0-rc6 2015-03-31 09:08:13 +02:00
kvm KVM: arm/arm64: remove now unneeded include directory from Makefile 2015-03-26 21:43:13 +00:00
lib arm64: __clear_user: handle exceptions on strb 2014-11-13 15:21:26 +00:00
mm arm64: Honor __GFP_ZERO in dma allocations 2015-03-20 18:18:54 +00:00
net arm64: bpf: lift restriction on last instruction 2014-12-03 18:04:09 +00:00
xen arm: xen: implement multicall hypercall support. 2014-04-24 13:09:46 +01:00
Kconfig ARM: SoC 64-bit changes and additions 2015-02-17 09:47:46 -08:00
Kconfig.debug arm64: add better page protections to arm64 2015-01-22 14:54:29 +00:00
Makefile arm64 updates for 3.20: 2015-02-11 18:03:54 -08:00