[BUG] tty: TIOCSSOFTCAR ignores a locked CLOCAL

From: Cheng Yongkang

Date: Sun Nov 15 2026 - 11:36:42 EST


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