From: Kishon Vijay Abraham I <kishon@ti.com>
To: Shunsuke Mie <mie@igel.co.jp>
Cc: <lorenzo.pieralisi@arm.com>, <bhelgaas@google.com>,
<linux-pci@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<stable@vger.kernel.org>
Subject: Re: [PATCH] PCI: endpoint: Fix use after free in pci_epf_remove_cfs()
Date: Tue, 7 Dec 2021 12:56:41 +0530 [thread overview]
Message-ID: <ed4de030-e0b3-503f-f0dc-75b103769dfc@ti.com> (raw)
In-Reply-To: <20210621070058.37682-1-mie@igel.co.jp>
Hi Shunsuke,
On 21/06/21 12:30 pm, Shunsuke Mie wrote:
> All of entries are freed in a loop, however, the freed entry is accessed
> by list_del() after the loop.
>
> When epf driver that includes pci-epf-test unload, the pci_epf_remove_cfs()
> is called, and occurred the use after free. Therefore, kernel panics
> randomly after or while the module unloading.
>
> I tested this patch with r8a77951-Salvator-xs boards.
Can you provide the crash dump?
>
> Fixes: ef1433f ("PCI: endpoint: Create configfs entry for each pci_epf_device_id table entry")
> Signed-off-by: Shunsuke Mie <mie@igel.co.jp>
> ---
> drivers/pci/endpoint/pci-epf-core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c
> index e9289d10f822..538e902b0ba6 100644
> --- a/drivers/pci/endpoint/pci-epf-core.c
> +++ b/drivers/pci/endpoint/pci-epf-core.c
> @@ -202,8 +202,10 @@ static void pci_epf_remove_cfs(struct pci_epf_driver *driver)
> 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(&group->group_entry);
Need full crash dump to see if this is really required or not. Ideally this
should be handled by configfs (or a configfs API could be used).
Thanks,
Kishon
next prev parent reply other threads:[~2021-12-07 7:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-21 7:00 Shunsuke Mie
2021-06-21 8:39 ` Greg KH
2021-12-06 11:45 ` Lorenzo Pieralisi
2021-12-07 7:26 ` Kishon Vijay Abraham I [this message]
2021-12-07 7:44 ` Shunsuke Mie
2021-12-10 11:09 ` Shunsuke Mie
-- strict thread matches above, loose matches on Subject: below --
2021-06-11 3:50 Shunsuke Mie
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=ed4de030-e0b3-503f-f0dc-75b103769dfc@ti.com \
--to=kishon@ti.com \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=mie@igel.co.jp \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®