The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: Frank Li <Frank.li@oss.nxp.com>,
	Shuangpeng Bai <shuangpeng.kernel@gmail.com>,
	kwilczynski@kernel.org, kishon@kernel.org, Frank.Li@kernel.org,
	arnd@arndb.de, bhelgaas@google.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] misc: pci_endpoint_test: fix use-after-free after device unbind
Date: Sat, 27 Jun 2026 18:29:28 +0100	[thread overview]
Message-ID: <2026062714-pretense-disprove-c1c9@gregkh> (raw)
In-Reply-To: <ambziiyr5u3653hihvvsg54fdhefcfme5hwbywgkthoo7hvxl4@xfgug6vq6dkx>

On Sat, Jun 27, 2026 at 06:29:07PM +0530, Manivannan Sadhasivam wrote:
> On Mon, Jun 22, 2026 at 03:40:43PM -0500, Frank Li wrote:
> > On Mon, Jun 22, 2026 at 12:52:49PM -0400, Shuangpeng Bai wrote:
> > > [You don't often get email from shuangpeng.kernel@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> > >
> > > An open miscdevice file descriptor can outlive the PCI driver binding.
> > > misc_deregister() removes the device node and prevents new opens, but it
> > > does not revoke file descriptors that are already open.
> > >
> > > Before this change, pci_endpoint_test stored the miscdevice inside struct
> > > pci_endpoint_test, and ioctl() recovered the test object from
> > > file->private_data with container_of(). Since the test object was allocated
> > > with devm_kzalloc(), it was freed when the PCI device was unbound. A
> > > process could therefore open /dev/pci-endpoint-test.N, unbind the PCI
> > > device through sysfs, and then issue an ioctl on the stale file descriptor,
> > > causing a use-after-free of struct pci_endpoint_test.
> > 
> > Anyways to provent unbound when still open? This driver is only for test
> > ednpoint funciton, it is not worth to make complex for this unusual case.
> > 
> 
> I disagree here. Even though this is a simple test driver, this is exposing an
> IOCTL to userspace. So the driver should take all necessary steps to prevent
> security issues like UAF.

That UAF can ONLY happen if root causes it to happen :)

  reply	other threads:[~2026-06-27 17:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-14 22:16 [BUG] KASAN: slab-use-after-free in pci_endpoint_test_ioctl Shuangpeng Bai
2026-06-15  2:39 ` Greg KH
2026-06-15 20:06   ` Shuangpeng
2026-06-18  3:01 ` Krzysztof Wilczyński
2026-06-21  5:46 ` [PATCH] misc: pci_endpoint_test: fix use-after-free after device unbind Shuangpeng Bai
2026-06-22 16:52   ` [PATCH v2] " Shuangpeng Bai
2026-06-22 20:40     ` Frank Li
2026-06-24  4:07       ` Shuangpeng
2026-06-27 12:59       ` Manivannan Sadhasivam
2026-06-27 17:29         ` Greg KH [this message]
2026-06-27 13:16     ` Manivannan Sadhasivam

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=2026062714-pretense-disprove-c1c9@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=Frank.Li@kernel.org \
    --cc=Frank.li@oss.nxp.com \
    --cc=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=kishon@kernel.org \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=shuangpeng.kernel@gmail.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