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=-2.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 D3237C4CEC4 for ; Mon, 16 Sep 2019 02:58:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A8D43206C2 for ; Mon, 16 Sep 2019 02:58:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Q5znqb7F" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728784AbfIPC63 (ORCPT ); Sun, 15 Sep 2019 22:58:29 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:44282 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725980AbfIPC63 (ORCPT ); Sun, 15 Sep 2019 22:58:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Sender:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=GVblmzz3plDyZtzevh+6JM/SYfAETob1wlVIQfguZMY=; b=Q5znqb7FLZyKO6G3Fd8YkzOdS gBtErLvRHK6K+fuDcQ14TIKk2mS3fqbsPc/9fXX0DONyfDqzCj4uoVnNlvOQG160mZSF2N/SH/Mod HqKkcPLzsabRH0rBKg+uK2CprPJX7X/iiEbCkYPcNRSAWZSMjEaPApVHQnwX11ThyYUzx4d0C2mXu RnFzj2P4/alRvj8v0W16o7fuZJHK8CMi+2mEowU/0J7v2SD+DKsAtc6GhSRHyJe3ox4MIDrN35IjB IpUi3OmrODCCyA/jA967/spy6CIXR1FJ76yxQ7Jhg/5GQbpymTgtRinUgmPTB+JpvgiR7W8fOs91y LLUylJDBQ==; Received: from [2601:1c0:6280:3f0::9a1f] by bombadil.infradead.org with esmtpsa (Exim 4.92.2 #3 (Red Hat Linux)) id 1i9hDc-00080R-Eq; Mon, 16 Sep 2019 02:58:24 +0000 Subject: Re: pci: endpoint test BUG To: Hillf Danton Cc: linux-pci , LKML , Kishon Vijay Abraham I , Lorenzo Pieralisi , Al Viro References: <20190916020630.1584-1-hdanton@sina.com> From: Randy Dunlap Message-ID: Date: Sun, 15 Sep 2019 19:58:22 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190916020630.1584-1-hdanton@sina.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/15/19 7:06 PM, Hillf Danton wrote: > > On Sun, 15 Sep 2019 09:34:37 -0700 >> >> Kernel is 5.3-rc8 on x86_64. >> >> Loading and removing the pci-epf-test module causes a BUG. >> >> >> [40928.435755] calling pci_epf_test_init+0x0/0x1000 [pci_epf_test] @ 12132 >> [40928.436717] initcall pci_epf_test_init+0x0/0x1000 [pci_epf_test] returned 0 after 891 usecs >> [40936.996081] ================================================================== >> [40936.996125] BUG: KASAN: use-after-free in pci_epf_remove_cfs+0x1ae/0x1f0 >> [40936.996153] Write of size 8 at addr ffff88810a22a068 by task rmmod/12139 > > Fix fb0de5b8dcc6 and ef1433f717a2 if the current group::group_entry > used by pci epf does not break how configfs uses it. > > --- a/drivers/pci/endpoint/pci-epf-core.c > +++ b/drivers/pci/endpoint/pci-epf-core.c > @@ -153,9 +153,11 @@ static void pci_epf_remove_cfs(struct pc > return; > > mutex_lock(&pci_epf_mutex); > - list_for_each_entry_safe(group, tmp, &driver->epf_group, group_entry) > + list_for_each_entry_safe(group, tmp, &driver->epf_group, > + group_entry) { > + list_del_init(&group->group_entry); > pci_ep_cfs_remove_epf_group(group); > - list_del(&driver->epf_group); > + } > mutex_unlock(&pci_epf_mutex); > } > > Fixes the problem for me. Thanks. Tested-by: Randy Dunlap Please make a proper patch. -- ~Randy