[PATCH 1/4] KVM: arm64: vgic-its: Bound PINTID during ITE table restore

From: Paolo Bonzini

Date: Fri Dec 04 2026 - 12:57:57 EST


From: Raghavendra Rao Ananta <rananta@xxxxxxxxxx>

During ITS table restore (KVM_DEV_ARM_ITS_RESTORE_TABLES), vgic_its_restore_ite()
validates only that the restored interrupt ID satisfies `lpi_id >= VGIC_MIN_LPI`
(8192) and fails to validate the upper bound against max_lpis_propbaser(propbaser).

Since the ITE PINTID field is 32-bit (bits 47:16), a guest can plant an
out-of-range LPI INTID in its own in-memory ITS tables prior to restore.
When direct MSI forwarding attaches (via kvm_vgic_v4_set_forwarding()), this
unchecked intid causes two severe consequences:

1. Out-of-Bounds Memory Write:
In its_vlpi_map(), lpi_write_config() calculates the configuration byte
target address as `page_address(map->vm->vprop_page) + hwirq - 8192`.
Since vprop_page is a 64KB page-granular host allocation and hwirq is
unbounded, this causes a 1-byte read-modify-write up to 4GB past the
allocation into neighboring memory, with both the offset and written value
controlled by the guest.

2. Hardware Command Queue Wedge (Host MSI/IRQ DoS):
Immediately following the write, its_vlpi_map() issues a physical VMAPTI
command with `virt_id = map->vintid`. Because virt_id exceeds the hardware's
architected ID limits, the physical GICv4.1 ITS command queue halts on the
malformed descriptor. The hardware read pointer becomes stuck, causing all
subsequent ITS commands to time out and permanently breaking host-wide MSI
handling until reboot:

ITS cmd its_build_discard_cmd failed
ITS queue timeout (24768 24481)
ITS cmd its_build_mapd_cmd failed
ITS queue timeout (24800 24481)
ITS cmd its_build_vmapp_cmd failed

Fix this by validating the upper bound of lpi_id against max_lpis_propbaser()
in vgic_its_restore_ite(), mirroring the check in vgic_its_cmd_handle_mapi().

Fixes: eff484e0298d ("KVM: arm64: vgic-its: ITT save and restore")
Reported-by: Stefan Teodorescu <fane@xxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Raghavendra Rao Ananta <rananta@xxxxxxxxxx>
Signed-off-by: Damiano Melotti <melotti@xxxxxxxxxx>
Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx>
---
arch/arm64/kvm/vgic/vgic-its.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c
index 7e9b265b1f52..82f7d052efcb 100644
--- a/arch/arm64/kvm/vgic/vgic-its.c
+++ b/arch/arm64/kvm/vgic/vgic-its.c
@@ -2248,7 +2248,8 @@ static int vgic_its_restore_ite(struct vgic_its *its, u32 event_id,
if (!lpi_id)
return 1; /* invalid entry, no choice but to scan next entry */

- if (lpi_id < VGIC_MIN_LPI)
+ if (lpi_id < VGIC_MIN_LPI ||
+ lpi_id >= max_lpis_propbaser(kvm->arch.vgic.propbaser))
return -EINVAL;

offset = val >> KVM_ITS_ITE_NEXT_SHIFT;
--
2.56.1