Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4526443ybh; Tue, 6 Aug 2019 13:17:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvyT/VcfDjFo+vD2uTahp72wsXnAM8tKzkTF3yfK9qXLMEOKL+4D9bmLrVsm2zudqIK04y X-Received: by 2002:a17:90a:e397:: with SMTP id b23mr4822903pjz.140.1565122630839; Tue, 06 Aug 2019 13:17:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565122630; cv=none; d=google.com; s=arc-20160816; b=jYKcs0FxVRUfbNP171Oia53aLhovJJIMFCAME2/NiWQuL8bjp0vOaZRxP5a5G42Mad UPC2PVv3l3HJrwW4QQi49DiP/HZTQ82ne0sXPM4xWj2vjwKlElWgAvPdndBCtVVUnCDO Afqlty2A5gc4+R4E8RXbprWX3fIpq9Vspf70Ym/TvEItCT4ZTnF8PJwOXeeH1u1IGRni 5Oo6QbrsQGgD+GNo9eiyK6aLU77FsbPQ3p9H+OFS6p2fn5hxHhWKkFKmED4Af70kypny gICw4N9ZtvVfXLFMJ3t4qSQrLMcqxcNxFggd3o9qPeOOGoAE3akHxgclR6x1f7VX+N/T b45g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=HF4sCAYenAn/v7s/ImCCikZM19HpvFUPcy1LxwE6QmY=; b=SauIcAzW8HfRarWMPcd+uZUho6MCqde4ahvmP/nuA0WdHNaVaAhHwcb2qqYlai8Las HDMfaTPrE7FFb6XOBnVZe/LtqkmxjzF1S1ZrhXHOFV7ckqVk33yDy8EXCPo5bfxdijWv RnrpmwBmOE95Gd6V8/PQj/Tdu6LdfCWhGrpAO9DUxkRFqSUgLAK/9ZsHagl9oXs2l8Ab OoNKd2y55JL8q/gg5++rNiuSAeCswwYCJYG9NhMZQOfWvm/Ca+9o5/mP1ioTZlXY0jxx 0GX+M3NQyB0RUFsdfuXOb5a80sLWmYRQo7hxFWDPCo/ov1N+Jlff/W+iUTOfZZj1A02O JnLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ow2jBeqS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l4si15336968pjq.69.2019.08.06.13.16.55; Tue, 06 Aug 2019 13:17:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ow2jBeqS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726301AbfHFUQO (ORCPT + 99 others); Tue, 6 Aug 2019 16:16:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:33028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725881AbfHFUQO (ORCPT ); Tue, 6 Aug 2019 16:16:14 -0400 Received: from localhost (unknown [69.71.4.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E7AD82070C; Tue, 6 Aug 2019 20:16:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565122573; bh=CHdEFDdC6MO7xI0dc+/jQv+NXvBM8cI43X6TKLK577M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ow2jBeqS4Y7JdM2VwzqcvRHDfcYU5ouUMku8rA0TEMfRBQDVxyFec06eyKybYUgQj KySLkYju9Gy0giIsRKiwHVCe2w5O03hmfEqqL1u/EMaYF4M5aWvTCLomJ6ILbWLvTT r29xKNy6KNSqg5rwyLzneBnk8LV420HPO1gyF9MM= Date: Tue, 6 Aug 2019 15:16:11 -0500 From: Bjorn Helgaas To: Dexuan Cui Cc: "lorenzo.pieralisi@arm.com" , "linux-pci@vger.kernel.org" , Michael Kelley , Stephen Hemminger , "linux-hyperv@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "driverdev-devel@linuxdriverproject.org" , Sasha Levin , Haiyang Zhang , KY Srinivasan , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" , vkuznets , "marcelo.cerri@canonical.com" , "jackm@mellanox.com" Subject: Re: [PATCH v2] PCI: hv: Fix panic by calling hv_pci_remove_slots() earlier Message-ID: <20190806201611.GT151852@google.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for updating this. But you didn't update the subject line, which is really still a little too low-level. Maybe Lorenzo will fix this. Something like this, maybe? PCI: hv: Avoid use of hv_pci_dev->pci_slot after freeing it On Fri, Aug 02, 2019 at 10:50:20PM +0000, Dexuan Cui wrote: > > The slot must be removed before the pci_dev is removed, otherwise a panic > can happen due to use-after-free. > > Fixes: 15becc2b56c6 ("PCI: hv: Add hv_pci_remove_slots() when we unload the driver") > Signed-off-by: Dexuan Cui > Cc: stable@vger.kernel.org > --- > > Changes in v2: > Improved the changelog accordign to the discussion with Bjorn Helgaas: > https://lkml.org/lkml/2019/8/1/1173 > https://lkml.org/lkml/2019/8/2/1559 > > drivers/pci/controller/pci-hyperv.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c > index 6b9cc6e60a..68c611d 100644 > --- a/drivers/pci/controller/pci-hyperv.c > +++ b/drivers/pci/controller/pci-hyperv.c > @@ -2757,8 +2757,8 @@ static int hv_pci_remove(struct hv_device *hdev) > /* Remove the bus from PCI's point of view. */ > pci_lock_rescan_remove(); > pci_stop_root_bus(hbus->pci_bus); > - pci_remove_root_bus(hbus->pci_bus); > hv_pci_remove_slots(hbus); > + pci_remove_root_bus(hbus->pci_bus); > pci_unlock_rescan_remove(); > hbus->state = hv_pcibus_removed; > } > -- > 1.8.3.1 >