From patchwork Thu Aug 8 15:34:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1144071 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 464C9p1HC6z9sNx; Fri, 9 Aug 2019 01:35:10 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hvkRW-0004oD-D6; Thu, 08 Aug 2019 15:35:06 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hvkRT-0004n7-HR for kernel-team@lists.ubuntu.com; Thu, 08 Aug 2019 15:35:03 +0000 Received: from mail-qk1-f199.google.com ([209.85.222.199]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hvkRT-0002Cx-3A for kernel-team@lists.ubuntu.com; Thu, 08 Aug 2019 15:35:03 +0000 Received: by mail-qk1-f199.google.com with SMTP id e18so82688971qkl.17 for ; Thu, 08 Aug 2019 08:35:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AFkhtb62+tL1UHsZY54EUOI5HoPVLIUxgJhwj+ePLsU=; b=rH57IM+N+FfYV4bPSEuBgLifGXoPtTo5vGspzBE8xgbDtY9alwS562VAr1rA++CDsm TMKgEGc/o3fK2y1SPwI7NBNQevF8/jbZA1TipCDbRquO42fKenVfwbqc3/0f7XCmBoRP 9E/F+F9t+m9GFH7zi66WxhLaqareVyuHDYrASzUacjRbH8Yzgu9G4II40H1xgYqmGoWV cCTzOnYCya9lK5WU1JtdiMY+5tXfwJUniRukZMgEhTIThHcKgCK46DNH4tnhyq/7V67m USoj91f7dCwjHjfiKgMi+Sac20e//b4LySt31DgRiZTnAqJDwkfFGqQMtCB+vx8Kqv+D FwZA== X-Gm-Message-State: APjAAAXASRbmv57ltRUnty31L6Eb5ZgXUuzre7Lr9FydCpWIDkeIeX06 sd61CPHe6yziUljyjrW1ClSpCS7wZHnsc1Pm28Q858zkR0Az0L1KeDVtMlaaHsWDLlGFlSoavhD 5HDMTmRcQ6YwwgVlCD+fyOBWMFPgj5Qxc+RVZwq6p X-Received: by 2002:ae9:e411:: with SMTP id q17mr13527793qkc.465.1565278501684; Thu, 08 Aug 2019 08:35:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9vavoD2SLNJ1kjzF6VoQBdhSqZ1VQKzNleXIvxYyK6vUAJI8pT7cmt2Gu1rlvABZfl+7Dzg== X-Received: by 2002:ae9:e411:: with SMTP id q17mr13527769qkc.465.1565278501415; Thu, 08 Aug 2019 08:35:01 -0700 (PDT) Received: from gallifrey.routerd55abc.com ([2804:14c:4e3:5580:544c:b692:4c6f:1e31]) by smtp.gmail.com with ESMTPSA id l5sm41244404qte.9.2019.08.08.08.34.59 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 08 Aug 2019 08:35:00 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [d/azure][PATCH 2/2] UBUNTU: SAUCE: PCI: hv: Fix panic by calling hv_pci_remove_slots() earlier Date: Thu, 8 Aug 2019 12:34:53 -0300 Message-Id: <20190808153453.19957-3-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190808153453.19957-1-marcelo.cerri@canonical.com> References: <20190808153453.19957-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Dexuan Cui BugLink: https://bugs.launchpad.net/bugs/1837661 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 Signed-off-by: Marcelo Henrique Cerri Acked-by: Sultan Alsawaf --- 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 ae91e708796f..3bd94149b9d2 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -2714,8 +2714,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; }