WSL2-Linux-Kernel/drivers/base
Benson Leung f123db8e9d driver core : Fix use after free of dev->parent in device_shutdown
The put_device(dev) at the bottom of the loop of device_shutdown
may result in the dev being cleaned up. In device_create_release,
the dev is kfreed.

However, device_shutdown attempts to use the dev pointer again after
put_device by referring to dev->parent.

Copy the parent pointer instead to avoid this condition.

This bug was found on Chromium OS's chromeos-3.8, which is based on v3.8.11.
See bug report : https://code.google.com/p/chromium/issues/detail?id=297842
This can easily be reproduced when shutting down with
hidraw devices that report battery condition.
Two examples are the HP Bluetooth Mouse X4000b and the Apple Magic Mouse.
For example, with the magic mouse :
The dev in question is "hidraw0"
dev->parent is "magicmouse"

In the course of the shutdown for this device, the input event cleanup calls
a put on hidraw0, decrementing its reference count.
When we finally get to put_device(dev) in device_shutdown, kobject_cleanup
is called and device_create_release does kfree(dev).
dev->parent is no longer valid, and we may crash in
put_device(dev->parent).

This change should be applied on any kernel with this change :
d1c6c030fc

Cc: stable@vger.kernel.org
Signed-off-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-26 14:46:11 -07:00
..
power ACPI and power management updates for 3.12-rc1 2013-09-03 15:59:39 -07:00
regmap Driver core patches for 3.12-rc1 2013-09-03 11:37:15 -07:00
Kconfig
Makefile Merge remote-tracking branch 'origin/next' into kvm-ppc-next 2013-08-29 00:41:59 +02:00
attribute_container.c
base.h
bus.c driver core: add #include <linux/sysfs.h> to core files. 2013-08-27 10:24:15 -07:00
class.c
core.c driver core : Fix use after free of dev->parent in device_shutdown 2013-09-26 14:46:11 -07:00
cpu.c ACPI and power management updates for 3.12-rc1 2013-09-03 15:59:39 -07:00
dd.c
devres.c
devtmpfs.c
dma-buf.c dma-buf: Expose buffer size to userspace (v2) 2013-09-10 11:36:45 +05:30
dma-coherent.c
dma-contiguous.c
dma-mapping.c
driver.c driver core: add #include <linux/sysfs.h> to core files. 2013-08-27 10:24:15 -07:00
firmware.c
firmware_class.c firmware loader: fix pending_fw_head list corruption 2013-08-30 12:04:27 -07:00
hypervisor.c
init.c
isa.c
map.c
memory.c ACPI and power management updates for 3.12-rc1 2013-09-03 15:59:39 -07:00
module.c
node.c thp: account anon transparent huge pages into NR_ANON_PAGES 2013-09-12 15:38:03 -07:00
pinctrl.c
platform.c
reservation.c
soc.c
syscore.c
topology.c
transport_class.c