linux/virt/kvm/arm/vgic
Marc Zyngier 7d8b44c54e KVM: arm/arm64: vgic-its: Fix potential overrun in vgic_copy_lpi_list
vgic_copy_lpi_list() parses the LPI list and picks LPIs targeting
a given vcpu. We allocate the array containing the intids before taking
the lpi_list_lock, which means we can have an array size that is not
equal to the number of LPIs.

This is particularly obvious when looking at the path coming from
vgic_enable_lpis, which is not a command, and thus can run in parallel
with commands:

vcpu 0:                                        vcpu 1:
vgic_enable_lpis
  its_sync_lpi_pending_table
    vgic_copy_lpi_list
      intids = kmalloc_array(irq_count)
                                               MAPI(lpi targeting vcpu 0)
      list_for_each_entry(lpi_list_head)
        intids[i++] = irq->intid;

At that stage, we will happily overrun the intids array. Boo. An easy
fix is is to break once the array is full. The MAPI command will update
the config anyway, and we won't miss a thing. We also make sure that
lpi_list_count is read exactly once, so that further updates of that
value will not affect the array bound check.

Cc: stable@vger.kernel.org
Fixes: ccb1d791ab ("KVM: arm64: vgic-its: Fix pending table sync")
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
2018-03-26 10:56:49 +01:00
..
trace.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
vgic-debug.c KVM: arm/arm64: vgic: constify seq_operations and file_operations 2017-09-05 17:33:38 +02:00
vgic-init.c KVM: arm/arm64: Keep GICv2 HYP VAs in kvm_vgic_global_state 2018-03-19 13:04:06 +00:00
vgic-irqfd.c KVM: arm/arm64: vgic-irqfd: Fix MSI entry allocation 2017-11-29 16:46:12 +01:00
vgic-its.c KVM: arm/arm64: vgic-its: Fix potential overrun in vgic_copy_lpi_list 2018-03-26 10:56:49 +01:00
vgic-kvm-device.c KVM: arm/arm64: Register iodevs when setting redist base and creating VCPUs 2017-05-09 12:19:36 +02:00
vgic-mmio-v2.c KVM: arm/arm64: Support calling vgic_update_irq_pending from irq context 2017-11-06 16:23:10 +01:00
vgic-mmio-v3.c KVM: arm/arm64: GICv4: Add property field and per-VM predicate 2017-11-10 09:06:45 +01:00
vgic-mmio.c KVM: arm/arm64: vgic: Add missing irq_lock to vgic_mmio_read_pending 2018-03-14 18:28:41 +00:00
vgic-mmio.h KVM: arm/arm64: Separate guest and uaccess writes to dist {sc}active 2017-05-23 12:48:11 +02:00
vgic-v2.c KVM: arm/arm64: vgic: Disallow Active+Pending for level interrupts 2018-03-26 10:54:23 +01:00
vgic-v3.c KVM: arm/arm64: vgic: Disallow Active+Pending for level interrupts 2018-03-26 10:54:23 +01:00
vgic-v4.c KVM: arm64: Fix GICv4 init when called from vgic_its_create 2018-01-12 11:40:21 +01:00
vgic.c kvm/arm fixes for 4.16, take 2 2018-03-19 17:43:01 +00:00
vgic.h kvm/arm fixes for 4.16, take 2 2018-03-19 17:43:01 +00:00