mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-04 02:02:28 +09:00
KVM: arm/arm64: vgic: Fix potential deadlock when ap_list is long
[ Upstream commitd4a8061a7c] If the ap_list is longer than 256 entries, merge_final() in list_sort() will call the comparison callback with the same element twice, causing a deadlock in vgic_irq_cmp(). Fix it by returning early when irqa == irqb. Cc: stable@vger.kernel.org # 4.7+ Fixes:8e44474579("KVM: arm/arm64: vgic-new: Add IRQ sorting") Signed-off-by: Zenghui Yu <yuzenghui@huawei.com> Signed-off-by: Heyi Guo <guoheyi@huawei.com> [maz: massaged commit log and patch, added Fixes and Cc-stable] Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
06ab420a84
commit
aafa2889b8
@@ -199,6 +199,13 @@ static int vgic_irq_cmp(void *priv, struct list_head *a, struct list_head *b)
|
||||
bool penda, pendb;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* list_sort may call this function with the same element when
|
||||
* the list is fairly long.
|
||||
*/
|
||||
if (unlikely(irqa == irqb))
|
||||
return 0;
|
||||
|
||||
spin_lock(&irqa->irq_lock);
|
||||
spin_lock_nested(&irqb->irq_lock, SINGLE_DEPTH_NESTING);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user