Skip to contentSkip to conversation

ARM/vgic: Fix out-of-bounds accesses in vgic_mmio_write_sgir()

PATCH In review Andrew Cooper 3 participants 3 messages Mar 26, 2025 – Mar 27, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 (3<<24)|(ff<<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 an out-of-bounds write.

Fix this by changing case 0x3 to default.

Fixes 08c688ca6422 ("ARM: new VGIC: Add SGIR register handler")

---
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>

This vgic driver is explicity not security supported, hence no XSA.

---
 xen/arch/arm/vgic/vgic-mmio-v2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/arm/vgic/vgic-mmio-v2.c +2 -1
index 670b335db2c3..7d1391ac9b48 100644
@@ -104,7 +104,8 @@ static void vgic_mmio_write_sgir(struct vcpu *source_vcpu,
     case GICD_SGI_TARGET_SELF:                    /* this very vCPU only */
         targets = (1U << source_vcpu->vcpu_id);
         break;
-    case 0x3:                                     /* reserved */
+
+    default:
         return;
     }
 
Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw

Hi Andrew,

Quoted 7 lines · Andrew Cooper

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 (3<<24)|(ff<<16) to this register will skip the early exit, then enter bitmap_for_each() with targets not bound by nr_vcpus.

Quoted 8 lines

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 an out-of-bounds write.

Fix this by changing case 0x3 to default.

Fixes 08c688ca6422 ("ARM: new VGIC: Add SGIR register handler")
Quoted 25 lines

---
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>

This vgic driver is explicity not security supported, hence no XSA.

---
 xen/arch/arm/vgic/vgic-mmio-v2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/arm/vgic/vgic-mmio-v2.c +2 -1
index 670b335db2c3..7d1391ac9b48 100644
@@ -104,7 +104,8 @@ static void vgic_mmio_write_sgir(struct vcpu *source_vcpu,
     case GICD_SGI_TARGET_SELF:                    /* this very vCPU only */
         targets = (1U << source_vcpu->vcpu_id);
         break;
-    case 0x3:                                     /* reserved */
+
+    default:
         return;
     }
Signature · 1 line
WBR, Volodymyr
Reviewed-by
#2 lore raw
Quoted 15 lines · Volodymyr Babchuk

Hi Andrew,

Quoted 11 lines · Andrew Cooper

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 (3<<24)|(ff<<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 an out-of-bounds write.

Quoted 6 lines
Quoted 4 lines

Fix this by changing case 0x3 to default.

Fixes 08c688ca6422 ("ARM: new VGIC: Add SGIR register handler")
Quoted 28 lines
Quoted 25 lines

---
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>

This vgic driver is explicity not security supported, hence no XSA.

---
 xen/arch/arm/vgic/vgic-mmio-v2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/arm/vgic/vgic-mmio-v2.c +2 -1
index 670b335db2c3..7d1391ac9b48 100644
@@ -104,7 +104,8 @@ static void vgic_mmio_write_sgir(struct vcpu *source_vcpu,
     case GICD_SGI_TARGET_SELF:                    /* this very vCPU only */
         targets = (1U << source_vcpu->vcpu_id);
         break;
-    case 0x3:                                     /* reserved */
+
+    default:
         return;
     }
Signature · 1 line
WBR, Volodymyr