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=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 AD7B5C49ED7 for ; Fri, 20 Sep 2019 15:20:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7F297217F5 for ; Fri, 20 Sep 2019 15:20:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392136AbfITPUa (ORCPT ); Fri, 20 Sep 2019 11:20:30 -0400 Received: from foss.arm.com ([217.140.110.172]:46298 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388863AbfITPUa (ORCPT ); Fri, 20 Sep 2019 11:20:30 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E9D39337; Fri, 20 Sep 2019 08:20:29 -0700 (PDT) Received: from e121166-lin.cambridge.arm.com (e121166-lin.cambridge.arm.com [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 282FA3F575; Fri, 20 Sep 2019 08:20:29 -0700 (PDT) Date: Fri, 20 Sep 2019 16:20:26 +0100 From: Lorenzo Pieralisi To: Kishon Vijay Abraham I Cc: Hillf Danton , Randy Dunlap , linux-pci , LKML Subject: Re: pci: endpoint test BUG Message-ID: <20190920152026.GC10172@e121166-lin.cambridge.arm.com> References: <20190916020630.1584-1-hdanton@sina.com> <20190916112246.GA6693@e121166-lin.cambridge.arm.com> <815ad936-8b98-0931-89f7-b97922a7c77d@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <815ad936-8b98-0931-89f7-b97922a7c77d@ti.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 17, 2019 at 11:10:37AM +0530, Kishon Vijay Abraham I wrote: > > On 16/09/19 4:52 PM, Lorenzo Pieralisi wrote: > > On Mon, Sep 16, 2019 at 10:06:30AM +0800, 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); > >> } > > > Acked-by: Kishon Vijay Abraham I > > > > > Thank you Hillf. Kishon, can you confirm that's the proper fix for > > this bug please ? I would like to turn this into a patch and merge > > it in the upcoming merge window PR so it ought to be fairly quick, > > please let me know asap. Kishon, Hillf, can you turn it into a patch and send it asap please ? Thanks, Lorenzo