linux/drivers
Linus Torvalds 5c58ceff10 tty: make sure to flush any pending work when halting the ldisc
When I rewrote tty ldisc code to use proper reference counts (commits
65b770468e and cbe9352fa0) in order to avoid a race with hangup, the
test-program that Eric Biederman used to trigger the original problem
seems to have exposed another long-standing bug: the hangup code did the
'tty_ldisc_halt()' to stop any buffer flushing activity, but unlike the
other call sites it never actually flushed any pending work.

As a result, if you get just the right timing, the pending work may be
just about to execute (ie the timer has already triggered and thus
cancel_delayed_work() was a no-op), when we then re-initialize the ldisc
from under it.

That, in turn, results in various random problems, usually seen as a
NULL pointer dereference in run_timer_softirq() or a BUG() in
worker_thread (but it can be almost anything).

Fix it by adding the required 'flush_scheduled_work()' after doing the
tty_ldisc_halt() (this also requires us to move the ldisc halt to before
taking the ldisc mutex in order to avoid a deadlock with the workqueue
executing do_tty_hangup, which requires the mutex).

The locking should be cleaned up one day (the requirement to do this
outside the ldisc_mutex is very annoying, and weakens the lock), but
that's a larger and separate undertaking.

Reported-by: Eric W. Biederman <ebiederm@xmission.com>
Tested-by: Xiaotian Feng <xtfeng@gmail.com>
Tested-by: Yanmin Zhang <yanmin_zhang@linux.intel.com>
Tested-by: Dave Young <hidave.darkstar@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-08-25 09:12:43 -07:00
..
accessibility
acpi Merge branch 'misc-2.6.31' into release 2009-08-02 12:55:51 -04:00
amba
ata ahci: add workaround for on-board 5723s on some gigabyte boards 2009-08-12 06:21:32 -04:00
atm
auxdisplay
base PM / Driver Core: Kill dev_pm_ops platform warning for now 2009-08-10 23:41:18 +02:00
block mg_disk: Add missing ready status check on mg_write() 2009-07-28 08:57:33 +02:00
bluetooth headers: smp_lock.h redux 2009-07-12 12:22:34 -07:00
cdrom
char tty: make sure to flush any pending work when halting the ldisc 2009-08-25 09:12:43 -07:00
clocksource sh: CMT suspend/resume 2009-08-15 12:58:45 +09:00
connector connector: maintainer/mail update. 2009-07-21 12:43:51 -07:00
cpufreq [CPUFREQ] Make cpufreq suspend code conditional on powerpc. 2009-08-04 14:32:11 -04:00
cpuidle
crypto
dca
dio
dma Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/djbw/async_tx 2009-07-30 16:46:31 -07:00
edac amd64_edac: print debug statements only on error 2009-08-04 12:10:06 +02:00
eisa
firewire
firmware
gpio headers: smp_lock.h redux 2009-07-12 12:22:34 -07:00
gpu drm/radeon/kms: Fix radeon_gem_busy_ioctl harder. 2009-08-23 11:36:13 +10:00
hid Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid 2009-07-22 09:30:07 -07:00
hwmon hwmon: (asus_atk0110) Fix upper limit readings 2009-07-28 16:31:39 +02:00
i2c i2c-stu300: I2C STU300 stability updates 2009-08-20 22:27:58 +01:00
ide ide-tape: Don't leak kernel stack information 2009-07-21 20:36:25 -07:00
idle
ieee1394
ieee802154
infiniband
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2009-08-24 12:25:27 -07:00
isdn Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6 2009-08-04 15:38:34 -07:00
leds
lguest lguest and virtio: cleanup struct definitions to Linux style. 2009-07-30 16:03:46 +09:30
macintosh
mca
md Merge branch 'for-linus' of git://neil.brown.name/md 2009-08-18 13:54:08 -07:00
media V4L/DVB (12441): siano: read buffer overflow 2009-08-13 20:39:14 -03:00
memstick
message
mfd mfd: twl4030 irq fixes 2009-08-04 20:31:32 +02:00
misc cb710: use SG_MITER_TO_SG/SG_MITER_FROM_SG 2009-07-31 12:28:46 +02:00
mmc drivers/mmc: correct error-handling code 2009-08-07 10:39:56 -07:00
mtd [ARM] Orion NAND: Make asm volatile avoid GCC pushing ldrd out of the loop 2009-08-24 11:56:00 -04:00
net smc91x: let smc91x work well under netpoll 2009-08-23 22:59:04 -07:00
nubus
of of/mdio: Add support function for Ethernet fixed-link property 2009-07-22 09:27:18 -07:00
oprofile oprofile: reset bt_lost_no_mapping with other stats 2009-07-10 12:35:36 +02:00
parisc parisc: hppb.c - fix printk format strings 2009-08-02 15:42:39 +02:00
parport
pci PCI: check saved state before restore 2009-08-20 09:08:45 -07:00
pcmcia
platform Merge branch 'bugzilla-13825' into release 2009-08-02 12:36:01 -04:00
pnp
power Merge git://git.infradead.org/users/cbou/battery-2.6.31 2009-07-30 16:45:53 -07:00
pps
ps3
rapidio
regulator
rtc rtc: mark if rtc-cmos drivers were successfully registered 2009-07-29 19:10:35 -07:00
s390 [S390] drivers/s390: put NULL test before dereference 2009-08-23 18:10:00 +02:00
sbus
scsi [SCSI] mpt2sas: fix config request and diag reset deadlock 2009-08-14 09:16:05 -05:00
serial ARM: S3C64XX: serial: Fix a typo in Kconfig 2009-08-14 00:43:46 +01:00
sh
sn
spi spi_s3c24xx: fix transfer setup code 2009-08-18 16:31:13 -07:00
ssb Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6 2009-07-09 20:33:18 -07:00
staging Staging: rspiusb: Fix buffer overflow 2009-08-07 16:12:03 -07:00
tc
telephony headers: smp_lock.h redux 2009-07-12 12:22:34 -07:00
thermal
uio
usb USB: fix oops on disconnect in cdc-acm 2009-08-07 16:05:14 -07:00
uwb
video sh: skip disabled LCDC channels 2009-08-15 12:58:42 +09:00
virtio virtio: refactor find_vqs 2009-07-30 16:03:45 +09:30
vlynq
w1 drivers/w1/masters/omap_hdq.c: fix missing mutex unlock 2009-08-07 10:39:55 -07:00
watchdog Merge master.kernel.org:/home/rmk/linux-2.6-arm 2009-08-07 10:46:51 -07:00
xen
zorro
Kconfig
Makefile