The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Cc: Jiri Slaby <jirislaby@kernel.org>,
	Johan Hovold <johan@kernel.org>,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	stable@vger.kernel.org, Bin Yu <byu@xidian.edu.cn>,
	Cheng Wen <wencheng@xidian.edu.cn>
Subject: Re: [PATCH] tty: port: fix hangup of a reopened tty
Date: Mon, 30 Nov 2026 16:37:43 +0100	[thread overview]
Message-ID: <2026113039-untangled-headsman-e0cf@gregkh> (raw)
In-Reply-To: <20261130141413.10581-1-25031212351@stu.xidian.edu.cn>

On Mon, Nov 30, 2026 at 10:14:13PM +0800, YuanZhe Liu wrote:
> Drivers rely on tty_port_tty_vhangup() to synchronously hang up their
> port before releasing port resources at deregistration (e.g. on physical
> disconnect).
> 
> tty_vhangup() does nothing if the tty has already been hung up.  If the
> tty is reopened while still being referenced by another process, the new
> open may reactivate the port, but TTY_HUPPED is only cleared once the
> open has completed.  A hangup request during that window is therefore
> dropped and the port remains initialised while the driver tears down its
> port data.
> 
> A blocking open then ends up calling into the driver (e.g. dtr_rts() or
> carrier_raised()) with the port data already gone.
> 
> Make sure the port is shut down after tty_vhangup() also when the tty has
> already been hung up.
> 
> This was found while analysing a NULL-pointer dereference in
> pl2303_dtr_rts() on disconnect.
> 
> Fixes: b48820de8c1a ("tty: port: fix tty_port_tty_vhangup() race")
> Cc: stable@vger.kernel.org
> Co-developed-by: Bin Yu <byu@xidian.edu.cn>
> Signed-off-by: Bin Yu <byu@xidian.edu.cn>
> Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn>
> Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn>
> Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
> ---
>  drivers/tty/tty_port.c | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)

How was this found and tested?  And are you sure this isn't fixed in
newer kernel releases?  Johan did some work on the hangup path here, so
verifying if that fixed this or not would be good.

Also note that the pl2303 driver might have different issues than all
tty drivers due to them being on the usb bus...

thanks,

greg k-h

      reply	other threads:[~2026-11-30 15:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 14:14 [PATCH] tty: port: fix hangup of a reopened tty YuanZhe Liu
2026-11-30 15:37 ` Greg Kroah-Hartman [this message]

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=2026113039-untangled-headsman-e0cf@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=25031212351@stu.xidian.edu.cn \
    --cc=byu@xidian.edu.cn \
    --cc=jirislaby@kernel.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=wencheng@xidian.edu.cn \
    /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