mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: vgic-its: Reject ITS_REGS offsets above U32_MAX
@ 2026-11-10  5:07 Dan Carpenter
  2026-11-10 10:59 ` Marc Zyngier
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2026-11-10  5:07 UTC (permalink / raw)
  To: Eric Auger
  Cc: Marc Zyngier, Oliver Upton, Fuad Tabba, Joey Gouly,
	Steffen Eiden, Suzuki K Poulose, Zenghui Yu, Catalin Marinas,
	Will Deacon, Mark Rutland, Carlos López, Sascha Bischoff,
	Jackie Liu, Christoffer Dall, linux-arm-kernel, kvmarm,
	linux-kernel, Karthik Bhargavan, Clément Blaudeau

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@vger.kernel.org
Signed-off-by: Dan Carpenter <dan@cryspen.com>
---
 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-10 13:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10  5:07 [PATCH] KVM: arm64: vgic-its: Reject ITS_REGS offsets above U32_MAX Dan Carpenter
2026-11-10 10:59 ` Marc Zyngier
2026-11-10 13:38   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®