Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1619062ybv; Fri, 21 Feb 2020 00:24:24 -0800 (PST) X-Google-Smtp-Source: APXvYqy3tQcErU+V89Kk4DVIlLwVegRtcKewk5TPhY/sLQbtWallGKetrzrPUd60BwRF4hZMxdeu X-Received: by 2002:a05:6830:1f0c:: with SMTP id u12mr26672872otg.253.1582273464823; Fri, 21 Feb 2020 00:24:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273464; cv=none; d=google.com; s=arc-20160816; b=nceSea36uts+bedObVyzKcj4lfdvNihjovRvPx1pxUJlMutZC+yob8tu0ccseInrJ2 JeZuNupDlHk6oLNfu/pHhxFTsOjuz4o0OXyAUFJsFyXQ3hywsDwqH0HnUOGVb933lZzT F5fbUaz3+HWy/5Sq/Ko9/ZrOGNqKgp6E82RcnjPa9ETH/SCoiUWn7+xt4zMMX8nh+uqD 3D8VqqDvBzZ/r6nWWsXmkEz/qCAeZ89stJq6sTeP56CgbF5n1BJ8kdn2PA/CN8+98Bk5 b//pGHpo24C/YHK6B4CNoWh5qmAbjUTh5XY8kYmURJbLbDruUuUtB2va8FXrGABQnVi5 hlLA== 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=ROG2ardi33dI/X+xMc4ePD+4jhaAX/UBLL54cJpuBM4=; b=hAd5CssNf/8SGkjygpmvYbauvamzoMPiJhgZwhveQThPb9y/u5pj+smbN06bxG8xtd k93AzQ/IVFDJS6fdEjeg2dok/fvsZg2QLQLtP750a3O7E1DbcmemN/Ohc4RgxxP1YCX+ yo0GA5kO8OIKqbZpSj+B/3O9U1Cp21WvluozMK1XkRetWmn28JCg0h+IwXuVpxV9uUqw nGTH/VlGhE5+n006c0QAvK2c9uARTx3eqm2wJAHEeT8ytfmS4KePfAtJBKsZCP8+llfn VGLGH7n/R1fqhRlLb/ufnB6FbakCoNbRn/d+lDPddu3vOG97IO0FO5AS4D3ob7xPUQOn BCqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Us42cI4w; 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 f23si1124800oto.205.2020.02.21.00.24.13; Fri, 21 Feb 2020 00:24:24 -0800 (PST) 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=Us42cI4w; 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 S2388492AbgBUIXb (ORCPT + 99 others); Fri, 21 Feb 2020 03:23:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:35522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388486AbgBUIX2 (ORCPT ); Fri, 21 Feb 2020 03:23:28 -0500 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 95EA224697; Fri, 21 Feb 2020 08:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273408; bh=LiJe7Oagm1mNMXF6zMLtUS9MDYRytae+4NbXXsV9DaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Us42cI4wy5Ihk+NVP/r4zjhx6ZUr8gV3mjsSPVV3W0pf76uPQfuNokrAyP6OPhBJf wAcusXh3mPvMFhVLCZjvwCtxbiKAPEfPSmVZ52Ap3kL2mSptz3j8NfXKm45r6EVuto 8M0uA8gGbJ68UsvRJv4bQvBuemE1Cnfl0dv0VhoM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver OHalloran , Sam Bobroff , Michael Ellerman , Sasha Levin Subject: [PATCH 4.19 158/191] powerpc/sriov: Remove VF eeh_dev state when disabling SR-IOV Date: Fri, 21 Feb 2020 08:42:11 +0100 Message-Id: <20200221072309.787670966@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@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: Oliver O'Halloran [ Upstream commit 1fb4124ca9d456656a324f1ee29b7bf942f59ac8 ] When disabling virtual functions on an SR-IOV adapter we currently do not correctly remove the EEH state for the now-dead virtual functions. When removing the pci_dn that was created for the VF when SR-IOV was enabled we free the corresponding eeh_dev without removing it from the child device list of the eeh_pe that contained it. This can result in crashes due to the use-after-free. Signed-off-by: Oliver O'Halloran Reviewed-by: Sam Bobroff Tested-by: Sam Bobroff Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20190821062655.19735-1-oohall@gmail.com Signed-off-by: Sasha Levin --- arch/powerpc/kernel/pci_dn.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c index ab147a1909c8b..7cecc3bd953b7 100644 --- a/arch/powerpc/kernel/pci_dn.c +++ b/arch/powerpc/kernel/pci_dn.c @@ -257,9 +257,22 @@ void remove_dev_pci_data(struct pci_dev *pdev) continue; #ifdef CONFIG_EEH - /* Release EEH device for the VF */ + /* + * Release EEH state for this VF. The PCI core + * has already torn down the pci_dev for this VF, but + * we're responsible to removing the eeh_dev since it + * has the same lifetime as the pci_dn that spawned it. + */ edev = pdn_to_eeh_dev(pdn); if (edev) { + /* + * We allocate pci_dn's for the totalvfs count, + * but only only the vfs that were activated + * have a configured PE. + */ + if (edev->pe) + eeh_rmv_from_parent_pe(edev); + pdn->edev = NULL; kfree(edev); } -- 2.20.1