]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commit
ARM/vgic: Fix out-of-bounds accesses in vgic_mmio_write_sgir()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 26 Mar 2025 15:26:56 +0000 (15:26 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 27 Mar 2025 11:54:23 +0000 (11:54 +0000)
commitbe7f0cc651d8d02a95820792204c0558f1f29e03
tree55771ff484729cee235663c9b5eadbb19ae6f91f
parent2addc9f05130a9fb3aa65bd47ff314c47e7eaed4
ARM/vgic: Fix out-of-bounds accesses in vgic_mmio_write_sgir()

The switch() statement is over bits 24:25 (unshifted) of the guest provided
value.  This makes case 0x3: dead, and not an implementation of the 4th
possible state.

A guest which writes (0x3 << 24) | (0xff << 16) to this register will skip the
early exit, then enter bitmap_for_each() with targets not bound by nr_vcpus.

If the guest has fewer than 8 vCPUs, bitmap_for_each() will read off the end
of d->vcpu[] and use the resulting vcpu pointer to ultimately derive irq, and
perform out-of-bounds writes.

Fix this by changing case 0x3 to default.

Fixes: 08c688ca6422 ("ARM: new VGIC: Add SGIR register handler")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/vgic/vgic-mmio-v2.c