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 A64E9C3A5A2 for ; Tue, 3 Sep 2019 18:40:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7F74922DBF for ; Tue, 3 Sep 2019 18:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567536051; bh=pdKj0QZWCq1x/Mw/PsfKbxwopLIof0VAYlWIMXn+bqw=; h=Subject:To:Cc:From:Date:List-ID:From; b=wDMrTrkAdzxcrproP4fmCbWmlyyuTsg7yHmJqsmP+ORemd0UTIq5ro1AW8gX3xufN SW6hKfHsLNBzggjay7lIBXc253bkgZbDrgur+crmZ0phjBWAbjoh7AGIjL/Wx+3Yf8 kPLDk3wNhoUM9K3hLgwdv7DqacoSjLLNBOe2VK5Y= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725962AbfICSkv (ORCPT ); Tue, 3 Sep 2019 14:40:51 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:49639 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725883AbfICSkv (ORCPT ); Tue, 3 Sep 2019 14:40:51 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 5A43A2224E; Tue, 3 Sep 2019 14:40:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 03 Sep 2019 14:40:49 -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=k/txwi P+zYqXOq3+EznC9uhEATCJzva+59tmC9+sGrw=; b=N7Kdi8PVC5VfWp/Mys6wvH Tks27492cIyOKGI29UxzmbSfW0hXtXIuimNHwE94LH+ff0kMHjx33BJJ+JCX7xSy j7kFsJN0lOiB38u6GmGRf1swuA2l7rwJSNym9gMaIDFlE/ZqrW+P9XcRLKSZ3Tpa VJyrqeGf+TPmT9t3p88TJRW3F8ysu/ZycMF9aZuspx+qRk1NfEVp1xv9I4q36Hb2 vLrA7uHfBS1kcWpdleP8mPRO03Qf60TFMFgjparaTRcYalA1wbYPQw6C8aaRYNe8 leX1I3OOPVn4QFeeP3Gb6L6YtdwgAsaWIQ7CSFBdNerzPyFSl9VWhRjVyzDbZ1gA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrudejfedgleekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvffhfffkgggtgfesthekredttd dtlfenucfhrhhomhepoehgrhgvghhkhheslhhinhhugihfohhunhgurghtihhonhdrohhr gheqnecukfhppeekfedrkeeirdekledruddtjeenucfrrghrrghmpehmrghilhhfrhhomh epghhrvghgsehkrhhorghhrdgtohhmnecuvehluhhsthgvrhfuihiivgepfe 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 A362780063; Tue, 3 Sep 2019 14:40:48 -0400 (EDT) Subject: FAILED: patch "[PATCH] KVM: arm/arm64: vgic: Fix potential deadlock when ap_list is" failed to apply to 4.14-stable tree To: guoheyi@huawei.com, maz@kernel.org, will@kernel.org, yuzenghui@huawei.com Cc: From: Date: Tue, 03 Sep 2019 20:40:38 +0200 Message-ID: <1567536038225169@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.14-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);