Because multiple opens of /dev/tty only issue one actual open to the
authorMatthew Dillon <dillon@dragonflybsd.org>
Mon, 3 Apr 2006 21:32:23 +0000 (21:32 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Mon, 3 Apr 2006 21:32:23 +0000 (21:32 +0000)
commit84cca6ec73aa934f8eced2b31ac3c55e38b40ed5
treebadcf97a3a69640222140c30e795e24d23edadb1
parent7f8e5940e1051ad534c4c20ff5a0065d8879f697
Because multiple opens of /dev/tty only issue one actual open to the
underlying tty, unconditionally use FREAD|FWRITE for the VOP_OPEN/VOP_CLOSE
calls.  Otherwise the modes may not match up on final close.

Unconditionally reference the underlying tty when obtaining the lock for a
read or write of /dev/tty.  If we do not do this then it is possible for
the session reference to be ripped out from under us while we are obtaining
the lock and for the vnode to be reused for another purpose without our
knowledge.

Reported-by: Kyle Butt <kylebutt@gmail.com>
sys/kern/tty.c
sys/kern/tty_tty.c