alistair23-linux/drivers/char
Jiri Slaby f06fb543c1 TTY: ttyprintk, unregister tty driver on failure
When the tty_printk driver fails to create a node in sysfs, the system
crashes. It is because the driver registers a tty driver and frees it
without deregistering it first. The fix is easy: add a call to
tty_unregister_driver to the fail path.

This is very unlikely to happen in usual environment => no need for
stable.

The crash occurs at some place where we iterate over tty drivers
first. It may look like this:
BUG: unable to handle kernel paging request at ffffffffffffff84
IP: [<ffffffff81278d56>] tty_open+0xd6/0x650
PGD 1a0d067 PUD 1a0e067 PMD 0
Oops: 0000 [#1] PREEMPT SMP
Modules linked in:
CPU 0
Pid: 1183, comm: boot.localnet Tainted: G        W    3.5.0-rc7-next-20120716+ #369 Bochs Bochs
RIP: 0010:[<ffffffff81278d56>]  [<ffffffff81278d56>] tty_open+0xd6/0x650
RSP: 0018:ffff8800162b3b98  EFLAGS: 00010207
RAX: 0000000000000000 RBX: ffff880016ba6200 RCX: 0000000000002208
RDX: 0000000000000000 RSI: 00000000000000d0 RDI: ffffffff81a35080
RBP: ffff8800162b3c08 R08: ffffffff81276f42 R09: 0000000000400040
R10: ffff8800161dc005 R11: ffff8800188ee048 R12: 0000000000000000
R13: ffffffffffffff58 R14: 0000000000400040 R15: 0000000000008000
FS:  00007f3684abd700(0000) GS:ffff880018e00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffffffff84 CR3: 000000001503e000 CR4: 00000000000006f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process boot.localnet (pid: 1183, threadinfo ffff8800162b2000, task ffff8800188c5880)
Stack:
 ffff8800162b3c08 ffffffff81363d63 ffffffff81a62940 ffff8800189b4e88
 ffff8800188c5880 ffffffff81123180 0000000000000000 ffffffff18b20600
 0000000000000000 ffff8800189b4e88 ffff880016ba6200 ffff880018b20600
Call Trace:
 [<ffffffff81363d63>] ? kobj_lookup+0x103/0x160
 [<ffffffff81123180>] ? mount_fs+0x110/0x110
 [<ffffffff81123a9c>] chrdev_open+0x9c/0x1a0
 [<ffffffff81123a00>] ? cdev_put+0x30/0x30
 [<ffffffff8111de76>] do_dentry_open.isra.19+0x1e6/0x270
 [<ffffffff8111df65>] finish_open+0x65/0xa0
 [<ffffffff8112dc9e>] do_last.isra.52+0x26e/0xd80
 [<ffffffff8112b163>] ? inode_permission+0x13/0x50
 [<ffffffff8112b203>] ? link_path_walk+0x63/0x940
 [<ffffffff8112e85b>] path_openat+0xab/0x3d0
 [<ffffffff8112ef5d>] do_filp_open+0x3d/0xa0
 [<ffffffff8113ba72>] ? alloc_fd+0xd2/0x120
 [<ffffffff8111eee3>] do_sys_open+0xf3/0x1d0
 [<ffffffff8111efdc>] sys_open+0x1c/0x20
 [<ffffffff815b5fe2>] system_call_fastpath+0x16/0x1b

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Samo Pogacnik <samo_pogacnik@t-2.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-08-10 13:29:57 -07:00
..
agp agp/intel-agp: remove snb+ host bridge pciids 2012-06-25 21:10:35 +02:00
hw_random Virtio patches, mainly hotplugging fixes. 2012-07-30 13:24:37 -07:00
ipmi char/ipmi: remove local ioctl defines replaced by generic ones 2012-07-23 12:48:04 +02:00
mwave 8250: three way resolve of the 8250 diffs 2012-07-17 09:11:50 -07:00
pcmcia pcmcia,synclink_cs: fix termios port I missed 2012-07-19 15:40:46 -07:00
tpm Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security 2012-07-23 18:49:06 -07:00
xilinx_hwicap xilinx_hwicap: reset XHI_MAX_RETRIES 2012-04-19 19:09:18 -07:00
apm-emulation.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/apm 2012-04-05 17:34:30 -07:00
applicom.c drivers/char/applicom.c: fix information leak to userland 2010-10-27 18:03:14 -07:00
applicom.h
bfin-otp.c llseek: automatically add .llseek fop 2010-10-15 15:53:27 +02:00
bsr.c powerpc/BSR: cleanup the error path of bsr_init 2012-07-17 10:27:38 -07:00
ds1302.c Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
ds1620.c Merge branch 'llseek' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bkl 2010-10-22 10:52:56 -07:00
dsp56k.c Merge branch 'llseek' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bkl 2010-10-22 10:52:56 -07:00
dtlk.c Merge branch 'llseek' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bkl 2010-10-22 10:52:56 -07:00
efirtc.c Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
generic_nvram.c drivers: fix up various ->llseek() implementations 2011-07-20 20:47:58 -04:00
genrtc.c Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
hangcheck-timer.c
hpet.c printk(): add KERN_CONT where needed in hpet and vt code 2012-04-09 10:30:39 -07:00
i8k.c module_param: make bool parameters really bool (drivers & misc) 2012-01-13 09:32:20 +10:30
Kconfig ramoops: Move to fs/pstore/ram.c 2012-05-16 08:06:37 -07:00
lp.c Merge branch 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-03-29 18:12:23 -07:00
Makefile ramoops: Move to fs/pstore/ram.c 2012-05-16 08:06:37 -07:00
mbcs.c Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
mbcs.h Fix common misspellings 2011-03-31 11:26:23 -03:00
mem.c powerpc: Disable /dev/port interface on systems without an ISA bridge 2012-07-11 18:22:32 +10:00
misc.c switch device_get_devnode() and ->devnode() to umode_t * 2012-01-03 22:54:55 -05:00
mmtimer.c posix-timers: Cleanup namespace 2011-02-02 15:28:19 +01:00
msm_smd_pkt.c drivers/char/msm_smd_pkt.c: don't use IS_ERR() 2011-08-25 16:25:33 -07:00
mspec.c [IA64] Redefine ATOMIC_INIT and ATOMIC64_INIT to drop the casts 2012-07-26 10:55:26 -07:00
nsc_gpio.c
nvram.c Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
nwbutton.c Fix common misspellings 2011-03-31 11:26:23 -03:00
nwbutton.h
nwflash.c Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
pc8736x_gpio.c llseek: automatically add .llseek fop 2010-10-15 15:53:27 +02:00
ppdev.c drivers/char/ppdev.c: put gotten port value 2011-05-26 17:12:37 -07:00
ps3flash.c drivers/char: Add module.h to those who were using it implicitly 2011-10-31 19:31:40 -04:00
random.c random: mix in architectural randomness in extract_buf() 2012-07-27 22:37:20 -04:00
raw.c switch device_get_devnode() and ->devnode() to umode_t * 2012-01-03 22:54:55 -05:00
rtc.c Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
scx200_gpio.c llseek: automatically add .llseek fop 2010-10-15 15:53:27 +02:00
snsc.c Merge branch 'llseek' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bkl 2010-10-22 10:52:56 -07:00
snsc.h headers: kobject.h redux 2011-01-10 08:51:44 -08:00
snsc_event.c
sonypi.c sonypi: Use struct dev_pm_ops for power management 2012-07-01 13:31:14 +02:00
tb0219.c llseek: automatically add .llseek fop 2010-10-15 15:53:27 +02:00
tile-srom.c tile-srom.c driver: minor code cleanup 2012-04-02 12:14:10 -04:00
tlclk.c char: Fix typo in tlclk.c 2012-02-09 23:09:37 +01:00
toshiba.c Merge branch 'llseek' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bkl 2010-10-22 10:52:56 -07:00
ttyprintk.c TTY: ttyprintk, unregister tty driver on failure 2012-08-10 13:29:57 -07:00
uv_mmtimer.c BKL: remove extraneous #include <smp_lock.h> 2010-11-17 08:59:32 -08:00
virtio_console.c virtio: console: tell host of open ports after resume from s3/s4 2012-05-17 12:14:33 +03:00