linux-stable/drivers/tty
Jiri Slaby 24d406a6bf TTY: pty, fix pty counting
tty_operations->remove is normally called like:
queue_release_one_tty
 ->tty_shutdown
   ->tty_driver_remove_tty
     ->tty_operations->remove

However tty_shutdown() is called from queue_release_one_tty() only if
tty_operations->shutdown is NULL. But for pty, it is not.
pty_unix98_shutdown() is used there as ->shutdown.

So tty_operations->remove of pty (i.e. pty_unix98_remove()) is never
called. This results in invalid pty_count. I.e. what can be seen in
/proc/sys/kernel/pty/nr.

I see this was already reported at:
  https://lkml.org/lkml/2009/11/5/370
But it was not fixed since then.

This patch is kind of a hackish way. The problem lies in ->install. We
allocate there another tty (so-called tty->link). So ->install is
called once, but ->remove twice, for both tty and tty->link. The fix
here is to count both tty and tty->link and divide the count by 2 for
user.

And to have ->remove called, let's make tty_driver_remove_tty() global
and call that from pty_unix98_shutdown() (tty_operations->shutdown).

While at it, let's document that when ->shutdown is defined,
tty_shutdown() is not called.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Alan Cox <alan@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-23 10:10:38 -07:00
..
hvc powerpc/pseries: Fix hvc_vio.c build due to recent changes 2011-07-20 18:01:48 +10:00
ipwireless Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6 2011-05-24 13:28:35 -07:00
serial 8250: Fix race condition in serial8250_backup_timeout(). 2011-08-23 10:10:37 -07:00
vt Revert "tty: make receive_buf() return the amout of bytes received" 2011-06-04 06:33:24 +09:00
amiserial.c
bfin_jtag_comm.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
cyclades.c Merge branch 'trivial' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2011-05-26 13:19:00 -07:00
isicom.c
Kconfig n_tracerouter and n_tracesink ldisc additions. 2011-05-13 16:31:00 -07:00
Makefile n_tracerouter and n_tracesink ldisc additions. 2011-05-13 16:31:00 -07:00
moxa.c drivers/tty: use printk_ratelimited() instead of printk_ratelimit() 2011-07-01 15:35:45 -07:00
moxa.h
mxser.c drivers/tty: use printk_ratelimited() instead of printk_ratelimit() 2011-07-01 15:35:45 -07:00
mxser.h
n_gsm.c Merge branch 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6 2011-07-25 23:09:27 -07:00
n_hdlc.c Revert "tty: make receive_buf() return the amout of bytes received" 2011-06-04 06:33:24 +09:00
n_r3964.c Revert "tty: make receive_buf() return the amout of bytes received" 2011-06-04 06:33:24 +09:00
n_tracerouter.c n_tracerouter and n_tracesink ldisc additions. 2011-05-13 16:31:00 -07:00
n_tracesink.c n_tracerouter and n_tracesink ldisc additions. 2011-05-13 16:31:00 -07:00
n_tracesink.h n_tracerouter and n_tracesink ldisc additions. 2011-05-13 16:31:00 -07:00
n_tty.c Merge branch 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6 2011-07-25 23:09:27 -07:00
nozomi.c Merge branch 'trivial' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2011-05-26 13:19:00 -07:00
pty.c TTY: pty, fix pty counting 2011-08-23 10:10:38 -07:00
rocket.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
rocket.h
rocket_int.h
synclink.c
synclink_gt.c
synclinkmp.c
sysrq.c
tty_audit.c
tty_buffer.c tty_buffer: get rid of 'seen_tail' logic in flush_to_ldisc 2011-06-08 07:46:30 -07:00
tty_io.c TTY: pty, fix pty counting 2011-08-23 10:10:38 -07:00
tty_ioctl.c Merge branch 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6 2011-05-23 12:23:20 -07:00
tty_ldisc.c TTY: ldisc, do not close until there are readers 2011-06-07 10:16:54 -07:00
tty_mutex.c
tty_port.c