linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@infradead.org>
To: Hillf Danton <hdanton@sina.com>
Cc: linux-pci <linux-pci@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Al Viro <viro@ZenIV.linux.org.uk>
Subject: Re: pci: endpoint test BUG
Date: Sun, 15 Sep 2019 19:58:22 -0700	[thread overview]
Message-ID: <fc884b12-c083-2d9f-0ec5-95c293931ed2@infradead.org> (raw)
In-Reply-To: <20190916020630.1584-1-hdanton@sina.com>

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 <rdunlap@infradead.org>

Please make a proper patch.

-- 
~Randy

       reply	other threads:[~2019-09-16  2:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190916020630.1584-1-hdanton@sina.com>
2019-09-16  2:58 ` Randy Dunlap [this message]
2019-09-16 11:22 ` pci: endpoint test BUG Lorenzo Pieralisi
2019-09-17  5:40   ` Kishon Vijay Abraham I
2019-09-20 15:20     ` Lorenzo Pieralisi
2019-09-21  0:57       ` Randy Dunlap
2019-09-21  3:32         ` Randy Dunlap
     [not found]         ` <c2cadd96-a6d5-45f9-9abc-4c89b4a8b056@VE1EUR03FT044.eop-EUR03.prod.protection.outlook.com>
2019-09-23  9:55           ` Lorenzo Pieralisi
2019-09-15 16:34 Randy Dunlap
2019-09-15 16:39 ` Al Viro
2019-09-15 19:48   ` Randy Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fc884b12-c083-2d9f-0ec5-95c293931ed2@infradead.org \
    --to=rdunlap@infradead.org \
    --cc=hdanton@sina.com \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).