* [BUG] tty: TIOCSSOFTCAR ignores a locked CLOCAL
@ 2026-11-15 16:36 Cheng Yongkang
0 siblings, 0 replies; only message in thread
From: Cheng Yongkang @ 2026-11-15 16:36 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby; +Cc: linux-serial, linux-kernel
Hi Greg, Jiri,
I hit a small inconsistency in tty_change_softcar(). It only matters
if an admin locks CLOCAL with TIOCSLCKTRMIOS, so it may not be worth
fixing. I am reporting it in case you want it.
Every other termios change in tty_ioctl.c goes through
tty_set_termios(), which applies the lock with unset_locked_termios().
tty_change_softcar() writes tty->termios directly and calls the
driver's ->set_termios(), so TIOCSSOFTCAR can change a locked CLOCAL.
It also skips the ldisc ->set_termios() call that tty_set_termios()
makes.
I only have a pty to test with, where CLOCAL itself means little. On
v7.3, root set and locked CLOCAL on a pty and then dropped to uid
65534, keeping the master fd. TIOCSSOFTCAR(0) returned 0 and cleared
CLOCAL, while TIOCGLCKTRMIOS still reported it locked. A following
TCSETS with CLOCAL=1 could not set it back, because the lock now kept
the changed value. The code is unchanged in next-20261113.
One way to fix it is to build the new termios in tty_change_softcar()
and pass it to tty_set_termios(). The lock and the ldisc call then
apply as for TCSETS, and the existing C_CLOCAL(tty) != bit check
returns -EINVAL when the bit is locked. I tested a smaller version
that returns -EPERM when CLOCAL is locked, not this one. I can send a
patch in whichever form you prefer.
Thanks,
Cheng Yongkang
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-15 16:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-15 16:36 [BUG] tty: TIOCSSOFTCAR ignores a locked CLOCAL Cheng Yongkang
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®