From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Chengfeng Ye <nicoyip.dev@gmail.com>
Cc: Jiri Slaby <jirislaby@kernel.org>,
Richard Watts <rrw@kynesim.co.uk>,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] tty: serialize device registration and removal
Date: Mon, 3 Aug 2026 16:20:07 +0200 [thread overview]
Message-ID: <2026080347-marsupial-clothing-b083@gregkh> (raw)
In-Reply-To: <20260731142220.3000214-1-nicoyip.dev@gmail.com>
On Fri, Jul 31, 2026 at 10:22:20PM +0800, Chengfeng Ye wrote:
> tty_cdev_add() stores a newly allocated cdev in driver->cdevs[index]
> before initializing and registering it. tty_unregister_device() reads and
> deletes the same pointer without serialization.
>
> The race can proceed as follows:
>
> registration removal
> ------------ -------
> driver->cdevs[index] = cdev
> cdev_del(driver->cdevs[index])
> kobject_put() frees cdev
> driver->cdevs[index]->ops = &tty_fops
>
> The final write accesses freed memory. Concurrent registration can also
> replace the slot while another caller is still using its cdev.
>
> KASAN reported:
>
> BUG: KASAN: slab-use-after-free in tty_cdev_add+0x5c7/0x670
> Write of size 8 at addr ffff88810b298c48
>
> Call Trace:
> tty_cdev_add+0x5c7/0x670
> tty_register_device_attr+0x458/0x810
> gsm_activate_mux+0x105/0x2e0
> gsmld_ioctl+0x92f/0x14d0
Hah, that's funny :)
Look in the mailing list archives for why we don't touch n_gsm issues,
ESPECIALLY by changing core tty code to work around the known
bugs/problems in that code base.
Your LLM should know not to run this code, please tell it to never do
so.
Also, you forgot to add an Assisted-by: tag :(
thanks,
greg k-h
next prev parent reply other threads:[~2026-08-03 14:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 14:22 Chengfeng Ye
2026-08-03 14:20 ` Greg Kroah-Hartman [this message]
2026-08-03 15:46 ` Chengfeng Ye
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=2026080347-marsupial-clothing-b083@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=nicoyip.dev@gmail.com \
--cc=rrw@kynesim.co.uk \
--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®