linux/drivers
Huajun Li bbfe8a71f0 scsi_scan: Fix 'Poison overwritten' warning caused by using freed 'shost'
commit 267a6ad4ae upstream.

In do_scan_async(), calling scsi_autopm_put_host(shost) may reference
freed shost, and cause Posison overwitten warning.
Yes, this case can happen, for example, an USB is disconnected just
when do_scan_async() thread starts to run, then scsi_host_put() called
in scsi_finish_async_scan() will lead to shost be freed(because the
refcount of shost->shost_gendev decreases to 1 after USB disconnects),
at this point, if references shost again, system will show following
warning msg.

To make scsi_autopm_put_host(shost) always reference a valid shost,
put it just before scsi_host_put() in function
scsi_finish_async_scan().

[  299.281565] =============================================================================
[  299.281634] BUG kmalloc-4096 (Tainted: G          I ): Poison overwritten
[  299.281682] -----------------------------------------------------------------------------
[  299.281684]
[  299.281752] INFO: 0xffff880056c305d0-0xffff880056c305d0. First byte
0x6a instead of 0x6b
[  299.281816] INFO: Allocated in scsi_host_alloc+0x4a/0x490 age=1688
cpu=1 pid=2004
[  299.281870] 	__slab_alloc+0x617/0x6c1
[  299.281901] 	__kmalloc+0x28c/0x2e0
[  299.281931] 	scsi_host_alloc+0x4a/0x490
[  299.281966] 	usb_stor_probe1+0x5b/0xc40 [usb_storage]
[  299.282010] 	storage_probe+0xa4/0xe0 [usb_storage]
[  299.282062] 	usb_probe_interface+0x172/0x330 [usbcore]
[  299.282105] 	driver_probe_device+0x257/0x3b0
[  299.282138] 	__driver_attach+0x103/0x110
[  299.282171] 	bus_for_each_dev+0x8e/0xe0
[  299.282201] 	driver_attach+0x26/0x30
[  299.282230] 	bus_add_driver+0x1c4/0x430
[  299.282260] 	driver_register+0xb6/0x230
[  299.282298] 	usb_register_driver+0xe5/0x270 [usbcore]
[  299.282337] 	0xffffffffa04ab03d
[  299.282364] 	do_one_initcall+0x47/0x230
[  299.282396] 	sys_init_module+0xa0f/0x1fe0
[  299.282429] INFO: Freed in scsi_host_dev_release+0x18a/0x1d0 age=85
cpu=0 pid=2008
[  299.282482] 	__slab_free+0x3c/0x2a1
[  299.282510] 	kfree+0x296/0x310
[  299.282536] 	scsi_host_dev_release+0x18a/0x1d0
[  299.282574] 	device_release+0x74/0x100
[  299.282606] 	kobject_release+0xc7/0x2a0
[  299.282637] 	kobject_put+0x54/0xa0
[  299.282668] 	put_device+0x27/0x40
[  299.282694] 	scsi_host_put+0x1d/0x30
[  299.282723] 	do_scan_async+0x1fc/0x2b0
[  299.282753] 	kthread+0xdf/0xf0
[  299.282782] 	kernel_thread_helper+0x4/0x10
[  299.282817] INFO: Slab 0xffffea00015b0c00 objects=7 used=7 fp=0x
      (null) flags=0x100000000004080
[  299.282882] INFO: Object 0xffff880056c30000 @offset=0 fp=0x          (null)
[  299.282884]
...

Signed-off-by: Huajun Li <huajun.li.lee@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-29 16:34:30 -08:00
..
accessibility
acpi PCI: Rework ASPM disable code 2012-02-06 09:24:01 -08:00
amba ARM: 6829/1: amba: make hardcoded periphid override hardware 2011-05-26 10:33:34 +01:00
ata ata_piix: make DVD Drive recognisable on systems with Intel Sandybridge chipsets(v2) 2011-11-11 09:35:50 -08:00
atm
auxdisplay
base firmware: Fix an oops on reading fw_priv->fw in sysfs loading file 2012-01-12 11:34:55 -08:00
bcma drivers/bcma/host_pci.c needs slab.h 2011-05-26 17:12:32 -07:00
block block: add and use scsi_blk_cmd_ioctl 2012-01-25 17:24:54 -08:00
bluetooth btusb: add device entry for Broadcom SoftSailing 2011-11-11 09:36:43 -08:00
cdrom block: add and use scsi_blk_cmd_ioctl 2012-01-25 17:24:54 -08:00
char TPM: Zero buffer after copying to userspace 2011-10-03 11:40:58 -07:00
clk
clocksource Revert "clocksource: sh_cmt: Runtime PM support" 2011-05-31 15:26:42 +09:00
connector Connector: Correctly set the error code in case of success when dispatching receive callbacks 2011-06-07 12:02:00 -07:00
cpufreq powernow-k8: Fix indexing issue 2012-02-13 11:06:13 -08:00
cpuidle Merge branch 'idle-release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-idle-2.6 2011-05-29 11:18:09 -07:00
crypto crypto: mv_cesa - fix hashing of chunks > 1920 bytes 2011-12-09 08:52:20 -08:00
dca
dio
dma at_hdmac: bugfix for enabling channel irq 2012-02-13 11:06:07 -08:00
edac i7core_edac: fixed typo in error count calculation 2011-08-29 13:29:06 -07:00
eisa
firewire firewire: ohci: disable MSI on Ricoh controllers 2012-02-13 11:06:06 -08:00
firmware ibft: Fix finding IBFT ACPI table on UEFI 2011-12-21 12:57:45 -08:00
gpio gpio/pca953x: Fix warning of enabled interrupts in handler 2012-02-20 12:48:11 -08:00
gpu drm/radeon/kms: fix MSI re-arm on rv370+ 2012-02-29 16:33:39 -08:00
hid HID: multitouch: add support for 3M 32" 2012-01-25 17:24:53 -08:00
hwmon hwmon: (ads1015) Fix file leak in probe function 2012-02-29 16:33:38 -08:00
hwspinlock hwspinlock/core: use a mutex to protect the radix tree 2011-11-11 09:36:31 -08:00
i2c i2c-eg20t: modified the setting of transfer rate. 2012-01-25 17:25:03 -08:00
ide block: add and use scsi_blk_cmd_ioctl 2012-01-25 17:24:54 -08:00
idle intel_idle: fix API misuse 2012-01-25 17:24:56 -08:00
ieee802154
infiniband IPoIB: Stop lying about hard_header_len and use skb->cb to stash LL addresses 2012-02-29 16:33:45 -08:00
input Input: synaptics - fix touchpad not working after S2R on Vostro V13 2012-01-06 14:13:49 -08:00
isdn net: Audit drivers to identify those needing IFF_TX_SKB_SHARING cleared 2011-08-15 18:31:38 -07:00
leds Revert "leds: save the delay values after a successful call to blink_set()" 2011-11-21 14:31:19 -08:00
lguest
macintosh
mca
md dm: do not forward ioctls from logical volumes to the underlying device 2012-01-25 17:24:54 -08:00
media uvcvideo: Fix integer overflow in uvc_ioctl_ctrl_map() 2012-01-25 17:24:50 -08:00
memstick
message
mfd mfd: Turn on the twl4030-madc MADC clock 2012-01-06 14:14:11 -08:00
misc mmc: cb710 core: Add missing spin_lock_init for irq_lock of struct cb710_chip 2012-02-13 11:06:13 -08:00
mmc mmc: core: check for zero length ioctl data 2012-02-29 16:33:42 -08:00
mtd UBI: fix debugging messages 2012-01-25 17:24:44 -08:00
net ath9k: stop on rates with idx -1 in ath9k rate control's .tx_status 2012-02-29 16:34:28 -08:00
nfc
nubus
of Merge branch 'devicetree/arm-next' of git://git.secretlab.ca/git/linux-2.6 into devel-stable 2011-05-25 00:08:17 +01:00
oprofile oprofile: Fix uninitialized memory access when writing to writing to oprofilefs 2012-01-06 14:13:51 -08:00
parisc
parport 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
pci PCI: workaround hard-wired bus number V2 2012-02-29 16:33:39 -08:00
pcmcia pcmcia: fix socket refcount decrementing on each resume 2012-02-13 11:06:10 -08:00
platform WMI: properly cleanup devices to avoid crashes 2011-11-11 09:36:09 -08:00
pnp PNP: work around Dell 1536/1546 BIOS MMCONFIG bug that breaks USB 2012-01-25 17:24:42 -08:00
power drivers/power/ds2780_battery.c: fix deadlock upon insertion and removal 2011-11-11 09:36:32 -08:00
pps
ps3
ptp ptp: Fix clock_getres() implementation 2011-12-21 12:57:36 -08:00
rapidio rapidio: fix use of non-compatible registers 2011-10-03 11:39:46 -07:00
regulator regulator: tps65910: Add missing breaks in switch/case 2011-10-03 11:40:01 -07:00
rtc drivers/rtc/interface.c: fix alarm rollover when day or month is out-of-range 2012-01-25 17:24:33 -08:00
s390 net: fix NULL dereferences in check_peer_redir() 2012-02-13 11:06:13 -08:00
sbus
scsi scsi_scan: Fix 'Poison overwritten' warning caused by using freed 'shost' 2012-02-29 16:34:30 -08:00
sfi
sh drivers: sh: resume enabled clocks fix 2011-06-14 15:15:25 +09:00
sn
spi spi/s3c64xx: Bug fix for SPI with different FIFO level 2011-07-06 15:03:08 +09:00
ssb ssb: fix init regression with SoCs 2012-01-06 14:13:48 -08:00
staging staging: r8712u: Add new Sitecom UsB ID 2012-02-13 11:06:12 -08:00
target target: Correct sense key for INVALID FIELD IN {PARAMETER LIST,CDB} 2012-02-13 11:06:11 -08:00
tc
telephony
thermal
tty drivers/tty/vt/vt_ioctl.c: fix KDFONTOP 32bit compatibility layer 2012-02-13 11:06:05 -08:00
uio
usb USB: Don't fail USB3 probe on missing legacy PCI IRQ. 2012-02-29 16:34:27 -08:00
uwb
vhost vhost: support event index 2011-05-30 11:14:15 +09:30
video atmel_lcdfb: fix usage of CONTRAST_CTR in suspend/resume 2012-02-13 11:06:09 -08:00
virtio virtio-pci: fix use after free 2011-11-21 14:31:14 -08:00
vlynq
w1 drivers/power/ds2780_battery.c: add a nolock function to w1 interface 2011-11-11 09:36:32 -08:00
watchdog watchdog: hpwdt: Changes to handle NX secure bit in 32bit path 2012-01-06 14:14:00 -08:00
xen xen/xenbus: Reject replies with payload > XENSTORE_PAYLOAD_MAX. 2012-01-25 17:24:41 -08:00
zorro zorro: Defer device_register() until all devices have been identified 2011-10-03 11:40:57 -07:00
Kconfig
Makefile Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/djbw/async_tx 2011-05-28 12:35:15 -07:00