Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp132651ybp; Thu, 3 Oct 2019 11:13:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5aBtkO3fzgRMHY7NGRmCv/DJMM1vXn6Q/7T6hF4mtdj2EeDFN1etkuLZLsQrEGkkU88wD X-Received: by 2002:a05:6402:1212:: with SMTP id c18mr10985602edw.259.1570126420241; Thu, 03 Oct 2019 11:13:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570126420; cv=none; d=google.com; s=arc-20160816; b=BM3PsC9ped1D2hPILWR6d0UErbRkami3bv5fLwqu6pZzJyDeTMIeBFuWC2eh59T36d 1DB9MU8lbjXVtn4ycql6weKbD4gsX4nFrY0PrgqXidFmN22V2pSzmYVzsM1DEbB+BeVk ZpMJIhjvrHAd2qM5Dv1HdFw47jhJpUzQ/xv/6Cz40xs9AVO80zPZhnxFMY+oGpxO9U44 NgshcbynnGDS1wZwxzqvhWQSlfmnUNe7pMp8SYo4xTKuj4F7XO4lyiLB1hydzUWJFIHQ 3eeprWdRlgC0txUD6yIgVNSMBtRQHK48i1aAyfRIG5eFa8dWuKsOuSDDP80tBsmRqI2G TuVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YbWGTFBtT1KKMSmv0HgGx33bp/ER7H2KAciWjHzy+hA=; b=bJzoi98GLOGeQH05b7Hs2ulBP72HAkQBDM6H4HsAA3fudQLx5Yze65yOn4e/krVTxX ADBMmcHcLlNGl5KZNVhQ6phcrK9iE34tPiQT4H1LwrVI+fWmaAKrkZCAJWm7vDmiwfQA SaiIkrBXV4E6h08BN3wmfOcBm+MxdcyLAgMS5BhtSjq5gNP5NAFNyZAZ5baLY1SsxJFF Ne2Gcm6+arqNAjoTJF+Id5LucLY3TbX6RrOnKINCt8rtIRy1fkkFlr2XEt0F1FpF72rY uWRWWohRWEz8ePYUXqyfsQi/5gF+hbaGU6wqpA2AyE9ucCpVHxhPqrhvw+sI85808V+d w9FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GnMC2Mrh; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oh20si1611333ejb.323.2019.10.03.11.13.15; Thu, 03 Oct 2019 11:13:40 -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=GnMC2Mrh; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732902AbfJCQHN (ORCPT + 99 others); Thu, 3 Oct 2019 12:07:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:54728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732879AbfJCQHG (ORCPT ); Thu, 3 Oct 2019 12:07:06 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 29B4D215EA; Thu, 3 Oct 2019 16:07:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570118825; bh=BdKXf97jE2/UC69PLNlnqNXE5Myg2bfbhBoXkFScitU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GnMC2Mrhp7/tyh8tjQ5B9lwjVHAbdyeSRgXSY1kNWm/4FvUQH8VaxEHVdjhywGqPg esMDoGm1iIevfrE8RrxQe1rsOpcC9dxbfFgCDwiqG9GlGajkaZZz16hG2Ps1pd7Bt8 vzaaUJkUN7LWPi9k1cdHDdv7kOsOmxVEIuGuTRtc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dexuan Cui , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH 4.14 023/185] PCI: hv: Avoid use of hv_pci_dev->pci_slot after freeing it Date: Thu, 3 Oct 2019 17:51:41 +0200 Message-Id: <20191003154442.941063740@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154437.541662648@linuxfoundation.org> References: <20191003154437.541662648@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dexuan Cui [ Upstream commit 533ca1feed98b0bf024779a14760694c7cb4d431 ] 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 Signed-off-by: Lorenzo Pieralisi Cc: stable@vger.kernel.org Signed-off-by: Sasha Levin --- drivers/pci/host/pci-hyperv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 5a9d945122327..70825689e5a08 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -2740,8 +2740,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; } -- 2.20.1