KVM: arm/arm64: vgic: Fix potential deadlock when ap_list is long
authorHeyi Guo <guoheyi@huawei.com>
Tue, 27 Aug 2019 11:26:50 +0000 (12:26 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Sep 2019 08:21:00 +0000 (10:21 +0200)
commitaafa2889b8fa98670e83d5f054e34ee1cbb44e96
tree0ec3390f5b524751f065ebfb5c6a43140ae7ec67
parent06ab420a84f0955360dca6c34faf2658d8cff1ce
KVM: arm/arm64: vgic: Fix potential deadlock when ap_list is long

[ Upstream commit d4a8061a7c5f7c27a2dc002ee4cb89b3e6637e44 ]

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: 8e4447457965 ("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>
virt/kvm/arm/vgic/vgic.c