From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 769C9C3A5A2 for ; Tue, 3 Sep 2019 18:40:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4C5702168B for ; Tue, 3 Sep 2019 18:40:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567536041; bh=0xW3kY+xInI+ODrUBVXb7nlzkRssMvu29NSzCZVYO+0=; h=Subject:To:Cc:From:Date:List-ID:From; b=SphneJiv6jyi90NXmb0mse+r+8VQdKeD+FyquPiyxnlXPCctzjZ8kA4PHvaMzpyf9 JoIQvC4eveI9K7TccCP0QbR+h7xqX3GsM0i0Xa58IJAXPe2mDgdqGzj+dvTVPJ63Ce oCVqncJbipYLNsvs6XL3cd6qFvKJ6eFV2wkuGqyU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725939AbfICSkl (ORCPT ); Tue, 3 Sep 2019 14:40:41 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:36019 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725883AbfICSkk (ORCPT ); Tue, 3 Sep 2019 14:40:40 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id A78502211C; Tue, 3 Sep 2019 14:40:39 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 03 Sep 2019 14:40:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=GtqY1z Cxfa2X1Ac8CqaLgwq3809Wp/xd6XIszOQtU0Y=; b=vGQFI5L9XMjuTYInpJME+P iAeRTvNtkGw9mYtVrJwj+ymShg1/JGwxLeK6mok2jTwJDh0q1IIp6lmbKL+4MeVA zfZRj+mO05u3BkDFPZAyOuXtOwHCVWtxuO5y8ZXm8AuEEzKQRaqsOz4xNhZyocjc dt+gre3O1PiPXjEquTjf9SyhdRZTzGaWE0h/L5lu9xbpTbWjEhveUi8sGvPAlGVU f/o/R3HqJx2/sIkrkHVcK0y4Cs32kBMdC/NmoVF9WVQ14SpgHaB8Yegs/Hd2iyDk JuuieQ7tCA02PhxeAgQF6TTkDaeVukGwzo5swuhTJGpvvi6jSg9KanRzW1QLUjCw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrudejfedgleekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvffhfffkgggtgfesthekredttd dtlfenucfhrhhomhepoehgrhgvghhkhheslhhinhhugihfohhunhgurghtihhonhdrohhr gheqnecukfhppeekfedrkeeirdekledruddtjeenucfrrghrrghmpehmrghilhhfrhhomh epghhrvghgsehkrhhorghhrdgtohhmnecuvehluhhsthgvrhfuihiivgepvd X-ME-Proxy: Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id CA9AFD6005F; Tue, 3 Sep 2019 14:40:38 -0400 (EDT) Subject: FAILED: patch "[PATCH] KVM: arm/arm64: vgic: Fix potential deadlock when ap_list is" failed to apply to 4.19-stable tree To: guoheyi@huawei.com, maz@kernel.org, will@kernel.org, yuzenghui@huawei.com Cc: From: Date: Tue, 03 Sep 2019 20:40:37 +0200 Message-ID: <1567536037189123@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 4.19-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From d4a8061a7c5f7c27a2dc002ee4cb89b3e6637e44 Mon Sep 17 00:00:00 2001 From: Heyi Guo Date: Tue, 27 Aug 2019 12:26:50 +0100 Subject: [PATCH] KVM: arm/arm64: vgic: Fix potential deadlock when ap_list is long 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 Signed-off-by: Heyi Guo [maz: massaged commit log and patch, added Fixes and Cc-stable] Signed-off-by: Marc Zyngier Signed-off-by: Will Deacon diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index 04786c8ec77e..ca5e6c6866a4 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -254,6 +254,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; + raw_spin_lock(&irqa->irq_lock); raw_spin_lock_nested(&irqb->irq_lock, SINGLE_DEPTH_NESTING);