From: Rodolfo Giometti <giometti@enneenne.com>
To: Danish Khateeb <danishkhateeb03@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Calvin Owens <calvin@wbinvd.org>, Yibo Tan <lhfff@tju.edu.cn>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2 1/4] pps: generators: fix use-after-free when closing a removed device
Date: Wed, 30 Sep 2026 14:07:59 +0200 [thread overview]
Message-ID: <83bf278d-ea13-4e1a-b6b2-a114051cd62c@enneenne.com> (raw)
In-Reply-To: <20260929124937.51114-2-danishkhateeb03@gmail.com>
On Tue, 29 Sep 2026 07:49:34 -0500, Danish Khateeb wrote:
> The cdev of a PPS generator is embedded in struct pps_gen_device, but
> nothing ties the lifetime of that structure to the cdev: pps_gen is
> freed by the release function of its device, and an open file holds a
> device reference only until pps_gen_cdev_release() drops it.
>
> When the generator is unregistered while /dev/pps-genN is open, that
> put_device() drops the last reference and frees pps_gen, and __fput()
> then calls cdev_put() on the freed cdev:
>
> BUG: KASAN: slab-use-after-free in cdev_put+0x53/0x60
> Read of size 8 at addr ffff88801383e138 by task ppsgen64/149
> Call Trace:
> cdev_put+0x53/0x60
> __fput+0x745/0xad0
> fput_close_sync+0xd9/0x1b0
> __x64_sys_close+0x86/0xf0
> ...
> Freed by task 149:
> kfree+0x25a/0x6d0
> device_release+0xca/0x3c0
> kobject_put+0x169/0x320
> pps_gen_cdev_release+0x51/0x80
> __fput+0x36a/0xad0
>
> pps.c had the same bug, fixed in commit c79a39dc8d06 ("pps: Fix a
> use-after-free").
>
> Fix it the usual way: embed the struct device in pps_gen_device and
> register both with cdev_device_add(). This makes the device the parent
> of the cdev, so the cdev holds a device reference until the last file
> is closed.
>
> Fixes: 86b525bed275 ("drivers pps: add PPS generators support")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Danish Khateeb <danishkhateeb03@gmail.com>
Acked-by: Rodolfo Giometti <giometti@enneenne.com>
next prev parent reply other threads:[~2026-09-30 12:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 12:49 [PATCH v2 0/4] pps: generators: fix use-after-free on unregister with the file open Danish Khateeb
2026-09-29 12:49 ` [PATCH v2 1/4] pps: generators: fix use-after-free when closing a removed device Danish Khateeb
2026-09-30 12:07 ` Rodolfo Giometti [this message]
2026-09-29 12:49 ` [PATCH v2 2/4] pps: generators: don't use the driver's info after unregister Danish Khateeb
2026-09-30 12:09 ` Rodolfo Giometti
2026-09-29 12:49 ` [PATCH v2 3/4] pps: generators: stop the generator on unregister Danish Khateeb
2026-09-30 12:10 ` Rodolfo Giometti
2026-09-29 12:49 ` [PATCH v2 4/4] pps: generators: wake up PPS_GEN_FETCHEVENT readers " Danish Khateeb
2026-09-30 12:10 ` Rodolfo Giometti
2026-09-30 12:07 ` [PATCH v2 0/4] pps: generators: fix use-after-free on unregister with the file open Rodolfo Giometti
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=83bf278d-ea13-4e1a-b6b2-a114051cd62c@enneenne.com \
--to=giometti@enneenne.com \
--cc=akpm@linux-foundation.org \
--cc=calvin@wbinvd.org \
--cc=danishkhateeb03@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=lhfff@tju.edu.cn \
--cc=linux-kernel@vger.kernel.org \
--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®