[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b914dbad-858c-42eb-80be-337e69f189e4@kernel.org>
Date: Wed, 24 Apr 2024 08:25:12 +0200
From: Jiri Slaby <jirislaby@...nel.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-kernel@...r.kernel.org,
Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>,
Andrew Morton <akpm@...ux-foundation.org>,
Daniel Starke <daniel.starke@...mens.com>,
syzbot <syzbot+dbac96d8e73b61aa559c@...kaller.appspotmail.com>
Subject: Re: [PATCH] tty: add the option to have a tty reject a new ldisc
On 23. 04. 24, 18:33, Linus Torvalds wrote:
> ... and use it to limit the virtual terminals to just N_TTY. They are
> kind of special, and in particular, the "con_write()" routine violates
> the "writes cannot sleep" rule that some ldiscs rely on.
>
> This avoids the
>
> BUG: sleeping function called from invalid context at kernel/printk/printk.c:2659
>
> when N_GSM has been attached to a virtual console, and gsmld_write()
> calls con_write() while holding a spinlock, and con_write() then tries
> to get the console lock.
..> --- a/drivers/tty/tty_ldisc.c
> +++ b/drivers/tty/tty_ldisc.c
> @@ -545,6 +545,12 @@ int tty_set_ldisc(struct tty_struct *tty, int disc)
> goto out;
> }
>
> + if (tty->ops->ldisc_ok) {
> + retval = tty->ops->ldisc_ok(tty, disc);
> + if (retval)
> + goto out;
This caught my eye as it looks like:
if (ldisc_ok)
die;
Perhaps dub it ldisc_check()? Alternatively, make it return a bool and
invert the logic here? That would make the ugly ternary in
con_ldisc_ok() go away too.
But whatever, it finally evades that group of bugs.
Now, I am not sure what the problem with attaching some weird ldisc to a
pty was. I will take a look next week (I am unavailable ATM).
thanks,
--
js
suse labs
Powered by blists - more mailing lists