linux/drivers/tty
Jiri Slaby fa90e1c935 TTY: make tty_add_file non-failing
If tty_add_file fails at the point it is now, we have to revert all
the changes we did to the tty. It means either decrease all refcounts
if this was a tty reopen or delete the tty if it was newly allocated.

There was a try to fix this in v3.0-rc2 using tty_release in 0259894c7
(TTY: fix fail path in tty_open). But instead it introduced a NULL
dereference. It's because tty_release dereferences
filp->private_data, but that one is set even in our tty_add_file. And
when tty_add_file fails, it's still NULL/garbage. Hence tty_release
cannot be called there.

To circumvent the original leak (and the current NULL deref) we split
tty_add_file into two functions, making the latter non-failing. In
that case we may do the former early in open, where handling failures
is easy. The latter stays as it is now. So there is no change in
functionality.

The original bug (leak) was introduced by f573bd176 (tty: Remove
__GFP_NOFAIL from tty_add_file()). Thanks Dan for reporting this.

Later, we may split tty_release into more functions and call only some
of them in this fail path instead. (If at all possible.)

Introduced-in: v2.6.37-rc2
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-10-18 14:22:37 -07:00
..
hvc hvc_console: display printk messages on console. 2011-10-18 14:17:10 -07: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_pci: Fix kernel panic when pch_uart is disabled 2011-10-18 14:19:54 -07:00
vt keyboard: Do not include <linux/irq.> 2011-09-22 16:05:08 -07:00
amiserial.c TTY: irq: Remove IRQF_DISABLED 2011-09-22 16:08:57 -07:00
bfin_jtag_comm.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
cyclades.c TTY: irq: Remove IRQF_DISABLED 2011-09-22 16:08:57 -07:00
ehv_bytechan.c drivers/tty: don't use the byte channel handle as a parameter in ehv_bytechan.c 2011-09-26 16:38:43 -07:00
isicom.c TTY: irq: Remove IRQF_DISABLED 2011-09-22 16:08:57 -07:00
Kconfig tty/powerpc: introduce the ePAPR embedded hypervisor byte channel driver 2011-08-23 10:32:56 -07:00
Makefile tty/powerpc: introduce the ePAPR embedded hypervisor byte channel driver 2011-08-23 10:32:56 -07:00
moxa.c drivers/tty: use printk_ratelimited() instead of printk_ratelimit() 2011-07-01 15:35:45 -07:00
moxa.h tty: move a number of tty drivers from drivers/char/ to drivers/tty/ 2011-02-22 16:14:56 -08:00
mxser.c TTY: mxser+cyclades remove wait_until_sent debug code 2011-08-23 10:34:07 -07:00
mxser.h Fix common misspellings 2011-03-31 11:26:23 -03:00
n_gsm.c tty/n_gsm: avoid fifo overflow in gsm_dlci_data_output 2011-09-26 16:39:23 -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: make tty_add_file non-failing 2011-10-18 14:22:37 -07:00
rocket.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
rocket.h tty: move a number of tty drivers from drivers/char/ to drivers/tty/ 2011-02-22 16:14:56 -08:00
rocket_int.h tty: move a number of tty drivers from drivers/char/ to drivers/tty/ 2011-02-22 16:14:56 -08:00
synclink.c drivers/tty/synclink: remove double comment 2011-08-23 10:32:56 -07:00
synclink_gt.c Fix common misspellings 2011-03-31 11:26:23 -03:00
synclinkmp.c TTY: snyclinkmp: forever loop in tx_load_dma_buffer() 2011-09-29 13:23:33 -07:00
sysrq.c lib, arch: add filter argument to show_mem and fix private implementations 2011-03-24 17:49:37 -07:00
tty_audit.c tty_audit: fix tty_audit_add_data live lock on audit disabled 2011-03-07 12:04:50 -08:00
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: make tty_add_file non-failing 2011-10-18 14:22:37 -07:00
tty_ioctl.c tty: Support compat_ioctl get/set termios_locked 2011-10-18 14:17:11 -07:00
tty_ldisc.c TTY: remove tty_locked 2011-08-23 10:34:07 -07:00
tty_mutex.c TTY: remove tty_locked 2011-08-23 10:34:07 -07:00
tty_port.c TTY: use tty_wait_until_sent_from_close in tty_port_close_start 2011-08-25 09:00:41 -07:00