diff options
| author | Dan Carpenter <dan@cryspen.com> | 2026-11-11 14:02:04 +0300 |
|---|---|---|
| committer | Marc Zyngier <maz@kernel.org> | 2026-11-11 11:24:27 +0000 |
| commit | 49703de92bfdb784447937a8d65ad6ef1db9b23d (patch) | |
| tree | 16eace48971d4b16e874eddca8dffc827d632115 /scripts | |
| parent | 736d91e59f079cc220ca348ae1d4b580f2ba0065 (diff) | |
KVM: arm64: vgic: Don't truncate offsets in vgic_find_mmio_region()
In vgic_its_has_attr_regs() and vgic_its_attr_regs_access() we take a
u64 "offset" from the user and pass it to vgic_find_mmio_region() to
find the correct region. The problem is that vgic_find_mmio_region()
truncates the "offset" to 32 bits so we might find a region even
though really we shouldn't.
Later the untruncated offset is used to calculate "addr".
addr = its->vgic_its_base + offset;
For example, an offset of 0x100000084 finds the 64-bit GITS_CBASER
register at 0x80, and the write reaches update_64bit_reg() with an
offset of 4 into the register and a length of 8. It exhibits as a
UBSAN warning.
[ 183.796046] UBSAN: shift-out-of-bounds in arch/arm64/kvm/vgic/vgic-mmio-v3.c:35:10
[ 183.796198] shift exponent 18446744073709551584 is too large for 64-bit type 'long long unsigned int'
The GICv5 IRS code has the same problem in vgic_v5_has_attr_regs() and
vgic_v5_irs_attr_regs_access().
Make vgic_find_mmio_region() and match_region() take the offset as a
u64, so an offset of 2^32 or more no longer matches any region. The
other callers only pass offsets which fit in 32 bits so they are not
affected.
Fortunately the effect of this bug is very minor. The worst case is that
the VMM accesses an emulated register and sets something nonsensical
and users are already allowed to do that without the bug.
Fixes: 8331c23c28e8 ("KVM: arm64: vgic-its: Implement vgic_its_has_attr_regs and attr_regs_access")
Fixes: 71091136d145 ("KVM: arm64: gic-v5: Handle userspace accesses to IRS MMIO region")
Signed-off-by: Dan Carpenter <dan@cryspen.com>
Link: https://patch.msgid.link/avRLLMOiudnKoSlk@stanley.mountain
Signed-off-by: Marc Zyngier <maz@kernel.org>
Diffstat (limited to 'scripts')
0 files changed, 0 insertions, 0 deletions
