Linux Serial subsystem development
 help / color / mirror / Atom feed
From: Cheng Yongkang <teel4res@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [BUG] tty: TIOCSSOFTCAR ignores a locked CLOCAL
Date: Sun, 15 Nov 2026 08:36:28 -0800	[thread overview]
Message-ID: <20261115163628.225925-1-teel4res@gmail.com> (raw)

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

                 reply	other threads:[~2026-11-15 16:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261115163628.225925-1-teel4res@gmail.com \
    --to=teel4res@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /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