From: Greg KH <gregkh@linuxfoundation.org>
To: Muhammad Bilal <meatuni001@gmail.com>
Cc: jirislaby@kernel.org, fseidel@suse.de,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tty: nozomi: lock tty_icount reads against the IRQ update path
Date: Wed, 23 Sep 2026 12:37:23 +0200 [thread overview]
Message-ID: <2026092340-disengage-broadcast-3542@gregkh> (raw)
In-Reply-To: <20260919192349.272409-1-meatuni001@gmail.com>
On Sun, Sep 20, 2026 at 12:23:49AM +0500, Muhammad Bilal wrote:
> receive_flow_control() updates port->tty_icount.{cts,dsr,rng,dcd}
> while interrupt_handler() holds dc->spin_mutex, but ntty_tiocgicount()
> and the TIOCMIWAIT snapshot/compare loop in ntty_ioctl()/
> ntty_cflags_changed() read the same multi-field struct with no lock
> at all. A concurrent update can be observed mid-copy, and KCSAN flags
> the unlocked access.
>
> Add ntty_get_icount() to snapshot port->tty_icount under
> dc->spin_mutex and use it at all three read sites, matching the lock
> already used on the update side.
>
> Fixes: 20fd1e3bea55 ("nozomi driver")
> Signed-off-by: Muhammad Bilal <meatuni001@gmail.com>
> ---
> drivers/tty/nozomi.c | 19 ++++++++++++++++---
> 1 file changed, 16 insertions(+), 3 deletions(-)
You forgot an Assisted-by: tag, right?
And how did you test this?
>
> diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
> index ed99dbc9f990..4b2e224c0aa2 100644
> --- a/drivers/tty/nozomi.c
> +++ b/drivers/tty/nozomi.c
> @@ -1671,10 +1671,23 @@ static int ntty_tiocmset(struct tty_struct *tty,
> return 0;
> }
>
> +static struct async_icount ntty_get_icount(struct port *port)
> +{
> + struct nozomi *dc = port->dc;
> + struct async_icount cnow;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&dc->spin_mutex, flags);
> + cnow = port->tty_icount;
> + spin_unlock_irqrestore(&dc->spin_mutex, flags);
> +
> + return cnow;
This is text-book LLM-written code as they do not know how to write
"modern" Linux kernel code. Please fix.
thanks,
greg k-h
prev parent reply other threads:[~2026-09-23 10:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 19:23 Muhammad Bilal
2026-09-23 10:37 ` Greg KH [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=2026092340-disengage-broadcast-3542@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=fseidel@suse.de \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=meatuni001@gmail.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
all inboxes | Powered by JetHome®