Linux Serial subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Johan Hovold" <johan@kernel.org>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH] tty: port: fix tty_port_tty_vhangup() race
Date: Thu, 10 Sep 2026 12:59:46 +0000	[thread overview]
Message-ID: <20260910125946.6886D1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260910125114.640880-1-johan@kernel.org>

> Drivers rely on tty_port_tty_vhangup() to synchronously hang up their
> ports before tearing down resources as part of deregistration (e.g. on
> physical disconnect).
> 
> If tty_port_tty_vhangup() races with another hangup it may however
> return before the port has been shut down. This is in turn can lead to
> use-after-free and NULL-pointer dereferences in racing ioctls (including
> a synchronous hangup) and in processing of racing asynchronous hangups
> (carrier loss).
> 
> Add the missing serialisation to tty_port_tty_vhangup() and
> tty_port_hangup() so that the former does not return until the port has
> been shut down also when there is a racing hangup.
> 
> Note that serial core does not use tty_port_hangup(), but it already
> holds the port mutex when clearing port->tty and shutting down the port
> in uart_hangup().
> 
> Fixes: 7ca0ff9ab321 ("tty: Add a full port_close function")
> Cc: stable@vger.kernel.org	# 2.6.32: 2b5eac0f8c6e: tty: introduce and use tty_port_tty_vhangup() helper
> Cc: stable@vger.kernel.org	# 2.6.32
> Reported-by: syzbot+5fabc1ae99ff40690d84@syzkaller.appspotmail.com
> Link: https://lore.kernel.org/6a944641.4d659fcc.734b4.003c.GAE@google.com
> Signed-off-by: Johan Hovold <johan@kernel.org>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260910125114.640880-1-johan@kernel.org?part=1


      reply	other threads:[~2026-09-10 12:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10 12:51 [PATCH] tty: port: fix tty_port_tty_vhangup() race Johan Hovold
2026-09-10 12:59 ` sashiko-bot [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=20260910125946.6886D1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=johan@kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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