]> www.infradead.org Git - users/jedix/linux-maple.git/commit
tty: Fix unsafe ldisc reference via ioctl(TIOCGETD)
authorPeter Hurley <peter@hurleysoftware.com>
Mon, 11 Jan 2016 06:40:55 +0000 (22:40 -0800)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 5 May 2016 21:02:45 +0000 (14:02 -0700)
commit45a0ab063ffa2fa5ba0e7214bd57ac555dec6c7c
tree4fd1c2f85e2be5aa25ea4625bdac613d87771a50
parent7c1b0f8ef1ab499a5cc67c2e86dc3234dba7fe05
tty: Fix unsafe ldisc reference via ioctl(TIOCGETD)

ioctl(TIOCGETD) retrieves the line discipline id directly from the
ldisc because the line discipline id (c_line) in termios is untrustworthy;
userspace may have set termios via ioctl(TCSETS*) without actually
changing the line discipline via ioctl(TIOCSETD).

However, directly accessing the current ldisc via tty->ldisc is
unsafe; the ldisc ptr dereferenced may be stale if the line discipline
is changing via ioctl(TIOCSETD) or hangup.

Wait for the line discipline reference (just like read() or write())
to retrieve the "current" line discipline id.

Cc: <stable@vger.kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 5c17c861a357e9458001f021a7afa7aab9937439)

Orabug: 23205576
CVE: CVE-2016-0723

Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
drivers/tty/tty_io.c