From: Jiri Slaby <jirislaby@kernel.org>
To: Haoli Zhang <26031212468@stu.xidian.edu.cn>, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
syzbot+2932e8970a6398db95c3@syzkaller.appspotmail.com,
25031212117@stu.xidian.edu.cn, byu@xidian.edu.cn
Subject: Re: [PATCH] tty: vt: protect tty lifetime in keyboard path
Date: Wed, 18 Nov 2026 07:05:09 +0100 [thread overview]
Message-ID: <86eea37d-632d-4c8a-b548-63907c7adee2@kernel.org> (raw)
In-Reply-To: <20261117091207.3950936-1-26031212468@stu.xidian.edu.cn>
On 17. 11. 26, 10:12, Haoli Zhang wrote:
> The KASAN report reaches stop_tty() through fn_hold(). That handler
> reads vc->port.tty and uses it without holding a tty reference. It runs
> under kbd_event_lock, while con_shutdown() clears the port association
> under console_lock; these locks do not protect the tty lifetime.
>
> Use the tty_port_tty guard in fn_hold() and keep the reference until
> start_tty() or stop_tty() returns. Keep kbd_keycode()'s existing tty
> reference interval unchanged.
>
> Use tty_port_tty_set() when installing and clearing the association so
> that updates use the same port lock as guarded reads and the port holds a
> tty reference while the association is active. A keyboard operation
> that already obtained a reference can then finish safely after shutdown
> clears the association.
>
> Reported-by: syzbot+2932e8970a6398db95c3@syzkaller.appspotmail.com
> Closes: https://syzbot.org/bug?extid=2932e8970a6398db95c3
> Co-developed-by: Jinning Zhang <25031212117@stu.xidian.edu.cn>
> Signed-off-by: Jinning Zhang <25031212117@stu.xidian.edu.cn>
> Co-developed-by: Bin Yu <byu@xidian.edu.cn>
> Signed-off-by: Bin Yu <byu@xidian.edu.cn>
> Signed-off-by: Haoli Zhang <26031212468@stu.xidian.edu.cn>
>
> ---
> drivers/tty/vt/keyboard.c | 34 ++++++++++++++++++++--------------
> drivers/tty/vt/vt.c | 4 ++--
> 2 files changed, 22 insertions(+), 16 deletions(-)
>
> --- a/drivers/tty/vt/keyboard.c
> +++ b/drivers/tty/vt/keyboard.c
> @@ -509,20 +509,26 @@
>
> static void fn_hold(struct vc_data *vc)
> {
> - struct tty_struct *tty = vc->port.tty;
> -
> - if (rep || !tty)
> - return;
> -
> - /*
> - * Note: SCROLLOCK will be set (cleared) by stop_tty (start_tty);
> - * these routines are also activated by ^S/^Q.
> - * (And SCROLLOCK can also be set by the ioctl KDSKBLED.)
> - */
> - if (tty->flow.stopped)
> - start_tty(tty);
> - else
> - stop_tty(tty);
> + struct tty_struct *tty;
> +
> + if (rep)
> + return;
> +
> + scoped_guard(tty_port_tty, &vc->port) {
> + tty = scoped_tty();
> + if (!tty)
> + return;
I am not sure whether you are a bot, but this is obviously wrong.
--
js
suse labs
prev parent reply other threads:[~2026-11-18 6:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 9:12 [PATCH] tty: vt: protect tty lifetime in keyboard path Haoli Zhang
2026-11-17 9:23 ` sashiko-bot
2026-11-18 6:05 ` Jiri Slaby [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=86eea37d-632d-4c8a-b548-63907c7adee2@kernel.org \
--to=jirislaby@kernel.org \
--cc=25031212117@stu.xidian.edu.cn \
--cc=26031212468@stu.xidian.edu.cn \
--cc=byu@xidian.edu.cn \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=syzbot+2932e8970a6398db95c3@syzkaller.appspotmail.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