From: Xiang Lei <leixiang@kylinos.cn>
To: gregkh@linuxfoundation.org
Cc: axboe@kernel.dk, bhelgaas@google.com, kch@nvidia.com,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
logang@deltatee.com
Subject: Re: [PATCH] PCI/P2PDMA: Fix use-after-free in pci_p2pdma_add_resource() error path
Date: Mon, 20 Jul 2026 09:16:49 +0800 [thread overview]
Message-ID: <20260720011649.23333-1-leixiang@kylinos.cn> (raw)
In-Reply-To: <2026071700-chitchat-uninsured-0767@gregkh>
On Fri, Jul 17, 2026 at 12:48:12PM +0200, Greg Kroah-Hartman wrote:
> On Fri, Jul 17, 2026 at 05:51:17PM +0800, leixiang wrote:
> > In pci_p2pdma_add_resource(), a devm action is registered to call
> > pci_p2pdma_unmap_mappings() with the 'p2p_pgmap' context. If the subsequent
> > call to gen_pool_add_owner() fails, the code jumps to the 'pages_free'
> > error path.
> >
> > In this error path, 'p2p_pgmap' is explicitly freed via devm_kfree().
> > However, the previously registered devm action is never removed. This
> > leaves a dangling pointer in the device's devres list. When the device
> > is unbound and devres is cleaning up resources, the unmap action will be
> > called with the already-freed 'p2p_pgmap', resulting in a use-after-free
> > bug.
> >
> > Fix this by properly calling devm_remove_action() in the error path before
> > freeing 'p2p_pgmap'.
> >
> > Fixes: 7e9c7ef83d78 ("PCI/P2PDMA: Allow userspace VMA allocations through sysfs")
> > Assisted-by: Antigravity:Gemini [tools]
> > Signed-off-by: leixiang <leixiang@kylinos.cn>
>
> We need a full name here, not just an email alias.
Hi Greg,
Thanks for pointing that out. I have updated my name and will send a v2 patch shortly.
Best regards,
Xiang Lei
next prev parent reply other threads:[~2026-07-20 1:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 9:51 leixiang
2026-07-17 10:48 ` Greg Kroah-Hartman
2026-07-20 1:16 ` Xiang Lei [this message]
2026-07-20 1:21 ` [PATCH v2] " Xiang Lei
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=20260720011649.23333-1-leixiang@kylinos.cn \
--to=leixiang@kylinos.cn \
--cc=axboe@kernel.dk \
--cc=bhelgaas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=kch@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=logang@deltatee.com \
/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®