Skip to content

Commit 91df7a9

Browse files
committed
KVM: arm64: vgic-its: Drop the translation cache reference only for the erased entry
cve CVE-2026-46316 commit-author Hyunwoo Kim <imv4bel@gmail.com> commit 13031fb vgic_its_invalidate_cache() walks the per-ITS translation cache with xa_for_each() and drops the cache's reference on each entry with vgic_put_irq(). It puts the iterated pointer, though, rather than the value returned by xa_erase(). The function is called from contexts that do not exclude one another: the ITS command handlers hold its_lock, the GITS_CTLR write path holds cmd_lock, and the path that clears EnableLPIs in a redistributor's GICR_CTLR holds neither. Two or more of them can drain the same cache concurrently, and if each one observes the same entry, erases it and then puts it, the single reference the cache holds on that entry is dropped more than once. The entry can then be freed while an ITE still maps it. xa_erase() is atomic and returns the previous entry, so put only the entry that this context actually removed. The cache reference is then dropped exactly once per entry even when the invalidations run concurrently, and the behavior is unchanged when only one context runs. Fixes: 8201d10 ("KVM: arm64: vgic-its: Maintain a translation cache per ITS") Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com> Reviewed-by: Oliver Upton <oupton@kernel.org> Link: https://patch.msgid.link/ah2c5lu4JbUg7dj-@v4bel Signed-off-by: Marc Zyngier <maz@kernel.org> Cc: stable@vger.kernel.org (cherry picked from commit 13031fb) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent f4a06fb commit 91df7a9

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

arch/arm64/kvm/vgic/vgic-its.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,10 @@ static void vgic_its_invalidate_cache(struct vgic_its *its)
627627
unsigned long idx;
628628

629629
xa_for_each(&its->translation_cache, idx, irq) {
630-
xa_erase(&its->translation_cache, idx);
631-
vgic_put_irq(kvm, irq);
630+
/* Only the context that erases the entry drops its cache ref. */
631+
irq = xa_erase(&its->translation_cache, idx);
632+
if (irq)
633+
vgic_put_irq(kvm, irq);
632634
}
633635
}
634636

0 commit comments

Comments
 (0)