[PATCH] KVM: arm64: vgic-its: Reject ITS_REGS offsets above U32_MAX
From: Dan Carpenter
Date: Tue Nov 10 2026 - 00:16:17 EST
The "offset" variable is a u64 that the user controls through the
KVM_SET_DEVICE_ATTR, KVM_GET_DEVICE_ATTR and KVM_HAS_DEVICE_ATTR
ioctls. The problem is vgic_find_mmio_region() truncates the u64 to a
u32, so it could return a valid region instead of failing. Then we
use the original incorrect value of "offset" to calculate "addr".
addr = its->vgic_its_base + offset;
The impact of this bug is relatively minor. A user in the kvm group
could potentially crash the VMM which they can already do without using
a bug.
Fixes: 8331c23c28e8 ("KVM: arm64: vgic-its: Implement vgic_its_has_attr_regs and attr_regs_access")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Dan Carpenter <dan@xxxxxxxxxxx>
---
arch/arm64/kvm/vgic/vgic-its.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c
index 5ce485485a11..532a82bed24c 100644
--- a/arch/arm64/kvm/vgic/vgic-its.c
+++ b/arch/arm64/kvm/vgic/vgic-its.c
@@ -2018,6 +2018,9 @@ static int vgic_its_has_attr_regs(struct kvm_device *dev,
gpa_t offset = attr->attr;
int align;
+ if (offset > U32_MAX)
+ return -ENXIO;
+
align = (offset < GITS_TYPER) || (offset >= GITS_PIDR4) ? 0x3 : 0x7;
if (offset & align)
@@ -2045,6 +2048,9 @@ static int vgic_its_attr_regs_access(struct kvm_device *dev,
its = dev->private;
offset = attr->attr;
+ if (offset > U32_MAX)
+ return -ENXIO;
+
/*
* Although the spec supports upper/lower 32-bit accesses to
* 64-bit ITS registers, the userspace ABI requires 64-bit
--
2.53.0