alistair23-linux/drivers
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
..
accessibility
acpi Merge branch 'linux-next' of git://cavan.codon.org.uk/platform-drivers-x86 2012-07-30 11:54:53 -07:00
amba Merge branch 'for-linus' of git://git.linaro.org/people/rmk/linux-arm 2012-07-27 15:14:26 -07:00
ata ARM: arm-soc Marvell Orion device-tree updates 2012-08-02 11:50:24 -07:00
atm
auxdisplay
base Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2012-08-01 10:26:23 -07:00
bcma Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless into for-davem 2012-07-27 11:15:03 -04:00
block Merge branch 'for-3.6/drivers' of git://git.kernel.dk/linux-block 2012-08-01 09:06:47 -07:00
bluetooth Merge tty-next into 3.6-rc1 2012-08-06 09:48:31 -07:00
cdrom
char TTY: ttyprintk, unregister tty driver on failure 2012-08-10 13:29:57 -07:00
clk clk: validate pointer in __clk_disable() 2012-07-30 17:25:13 -07:00
clocksource arm-soc: new SoC support 2012-07-23 16:31:31 -07:00
connector
cpufreq ARM: arm-soc soc updates, take 2 2012-07-30 09:45:53 -07:00
cpuidle Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux 2012-07-26 14:28:55 -07:00
crypto This patch series contains a major revamp of how we collect entropy 2012-07-31 19:07:42 -07:00
dca
devfreq
dio
dma SuperH fixes for 3.6-rc1 merge window 2012-08-02 11:45:42 -07:00
edac Merge branch 'devel' 2012-07-29 21:11:05 -03:00
eisa
extcon MFD bits for the 3.6 merge window. 2012-07-30 12:41:17 -07:00
firewire - Small fixes and optimizations. 2012-07-30 09:32:39 -07:00
firmware This patch series contains a major revamp of how we collect entropy 2012-07-31 19:07:42 -07:00
gpio MFD bits for the 3.6 merge window. 2012-07-30 12:41:17 -07:00
gpu Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2012-07-30 10:06:23 -07:00
hid Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 2012-07-31 18:47:44 -07:00
hsi
hv This patch series contains a major revamp of how we collect entropy 2012-07-31 19:07:42 -07:00
hwmon Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging 2012-07-30 10:10:26 -07:00
hwspinlock
i2c This patch series contains a major revamp of how we collect entropy 2012-07-31 19:07:42 -07:00
ide
idle Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux 2012-07-26 14:28:55 -07:00
ieee802154
iio
infiniband Merge branches 'cma', 'ipoib', 'ocrdma' and 'qib' into for-next 2012-07-30 07:47:27 -07:00
input This patch series contains a major revamp of how we collect entropy 2012-07-31 19:07:42 -07:00
iommu IOMMU Updates for Linux v3.6-rc1 2012-07-24 16:24:11 -07:00
isdn Merge tty-next into 3.6-rc1 2012-08-06 09:48:31 -07:00
leds leds-lp8788: forgotten unlock at lp8788_led_work 2012-07-27 08:16:07 +08:00
lguest
macintosh
md Additional md update for 3.6 2012-08-02 11:34:40 -07:00
media Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 2012-07-31 18:47:44 -07:00
memory
memstick
message drivers/message/i2o/i2o_config.c: bound allocation 2012-07-30 17:25:17 -07:00
mfd This patch series contains a major revamp of how we collect entropy 2012-07-31 19:07:42 -07:00
misc misc: pti, use tty_port_register_device 2012-08-10 13:29:57 -07:00
mmc Merge tty-next into 3.6-rc1 2012-08-06 09:48:31 -07:00
mtd Merge branch 'dmaengine' of git://git.linaro.org/people/rmk/linux-arm 2012-08-01 16:41:07 -07:00
net Merge tty-next into 3.6-rc1 2012-08-06 09:48:31 -07:00
nfc
nubus
of Devicetree updates for 3.6 2012-07-24 14:07:22 -07:00
oprofile
parisc PCI changes for the 3.6 merge window: 2012-07-24 16:17:07 -07:00
parport
pci PCI changes for the 3.6 merge window: 2012-07-24 16:17:07 -07:00
pcmcia Merge branch 'for-linus' of git://git.linaro.org/people/rmk/linux-arm 2012-07-27 15:14:26 -07:00
pinctrl Pin control changes for v3.6: 2012-07-24 14:05:46 -07:00
platform Platform: OLPC: move global variables into priv struct 2012-07-31 23:27:31 -04:00
pnp
power Merge branch 'for-linus-3.6' of git://dev.laptop.org/users/dilinger/linux-olpc 2012-08-02 11:52:39 -07:00
pps pps: return PTR_ERR on error in device_create 2012-07-30 17:25:21 -07:00
ps3
ptp
pwm pwm: pwm-tiehrpwm: PWM driver support for EHRPWM 2012-07-26 07:45:20 +02:00
rapidio
regulator regulator: Fix an s5m8767 build failure 2012-07-31 00:51:09 +02:00
remoteproc A batch of remoteproc patches for 3.6: 2012-07-26 16:19:08 -07:00
rpmsg A batch of remoteproc patches for 3.6: 2012-07-26 16:19:08 -07:00
rtc Merge branch 'akpm' (Andrew's patch-bomb) 2012-07-31 19:25:39 -07:00
s390 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2012-07-26 18:09:01 -07:00
sbus
scsi Merge branch 'for-3.6/core' of git://git.kernel.dk/linux-block 2012-08-01 09:02:41 -07:00
sfi
sh Merge branch 'common/irqdomain' into sh-latest 2012-08-01 17:14:52 +09:00
sn
spi Merge branch 'dmaengine' of git://git.linaro.org/people/rmk/linux-arm 2012-08-01 16:41:07 -07:00
ssb
staging ipoctal: make it compile with the termios changes 2012-08-10 13:02:10 -07:00
target Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2012-08-01 10:26:23 -07:00
tc
thermal The tag contains just a few battery-related changes for v3.6. It's is 2012-07-31 18:08:25 -07:00
tty mxser: allow overlapping vector 2012-08-10 13:29:57 -07:00
uio
usb tty: fix the metro-usb change I messed up 2012-08-10 12:53:30 -07:00
uwb
vfio vfio: Add PCI device driver 2012-07-31 08:16:24 -06:00
vhost vhost: make vhost work queue visible 2012-07-22 01:22:23 +03:00
video fbdev updates for 3.6 2012-08-01 10:45:12 -07:00
virt
virtio [SCSI] virtio-scsi: Add vdrv->scan for post VIRTIO_CONFIG_S_DRIVER_OK LUN scanning 2012-07-20 08:59:03 +01:00
vlynq
vme VME: Prevent D16 cycles being split into 8-bit blocks 2012-07-19 15:39:39 -07:00
w1 Driver core merge for 3.6-rc1 2012-07-26 11:25:33 -07:00
watchdog ARM: arm-soc Marvell Orion device-tree updates 2012-08-02 11:50:24 -07:00
xen PCI changes for the 3.6 merge window: 2012-07-24 16:17:07 -07:00
zorro
Kconfig vfio: VFIO core 2012-07-31 08:16:22 -06:00
Makefile vfio: VFIO core 2012-07-31 08:16:22 -06:00