1
0
Fork 0
alistair23-linux/drivers/thunderbolt
Mika Westerberg b92738c4f9 thunderbolt: Fix use-after-free in remove_unplugged_switch()
commit 600c0849cf upstream.

Paulian reported a crash that happens when a dock is unplugged during
hibernation:

[78436.228217] thunderbolt 0-1: device disconnected
[78436.228365] BUG: kernel NULL pointer dereference, address: 00000000000001e0
...
[78436.228397] RIP: 0010:icm_free_unplugged_children+0x109/0x1a0
...
[78436.228432] Call Trace:
[78436.228439]  icm_rescan_work+0x24/0x30
[78436.228444]  process_one_work+0x1a3/0x3a0
[78436.228449]  worker_thread+0x30/0x370
[78436.228454]  ? process_one_work+0x3a0/0x3a0
[78436.228457]  kthread+0x13d/0x160
[78436.228461]  ? kthread_park+0x90/0x90
[78436.228465]  ret_from_fork+0x1f/0x30

This happens because remove_unplugged_switch() calls tb_switch_remove()
that releases the memory pointed by sw so the following lines reference
to a memory that might be released already.

Fix this by saving pointer to the parent device before calling
tb_switch_remove().

Reported-by: Paulian Bogdan Marinca <paulian@marinca.net>
Fixes: 4f7c2e0d87 ("thunderbolt: Make sure device runtime resume completes before taking domain lock")
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-12-11 13:23:29 +01:00
..
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile thunderbolt: Add support for Intel Ice Lake 2019-08-26 12:15:06 +03:00
cap.c thunderbolt: Add dummy read after port capability list walk on Light Ridge 2019-04-18 11:18:51 +03:00
ctl.c thunderbolt: Do not fail adding switch if some port is not implemented 2019-08-26 12:14:51 +03:00
ctl.h thunderbolt: Add Intel as copyright holder 2018-10-02 15:52:08 -07:00
dma_port.c thunderbolt: Convert rest of the driver files to use SPDX identifier 2018-10-02 15:52:08 -07:00
dma_port.h thunderbolt: Convert rest of the driver files to use SPDX identifier 2018-10-02 15:52:08 -07:00
domain.c crypto: shash - remove shash_desc::flags 2019-04-25 15:38:12 +08:00
eeprom.c thunderbolt: Do not fail adding switch if some port is not implemented 2019-08-26 12:14:51 +03:00
icm.c thunderbolt: Fix use-after-free in remove_unplugged_switch() 2020-12-11 13:23:29 +01:00
lc.c thunderbolt: Set sleep bit when suspending switch 2019-04-18 11:18:52 +03:00
nhi.c thunderbolt: Add the missed ida_simple_remove() in ring_request_msix() 2020-11-18 19:20:29 +01:00
nhi.h thunderbolt: Add support for Intel Ice Lake 2019-08-26 12:15:06 +03:00
nhi_ops.c thunderbolt: Drop unnecessary read when writing LC command in Ice Lake 2019-10-08 12:08:21 +03:00
nhi_regs.h thunderbolt: Add support for Intel Ice Lake 2019-08-26 12:15:06 +03:00
path.c thunderbolt: Reword output of tb_dump_hop() 2019-04-18 11:18:54 +03:00
property.c thunderbolt: property: Fix a missing check of kzalloc 2019-03-28 11:30:47 +03:00
switch.c thunderbolt: Prevent crash if non-active NVMem file is read 2020-02-28 17:22:13 +01:00
tb.c thunderbolt: Make rest of the logging to happen at debug level 2019-04-18 11:18:53 +03:00
tb.h thunderbolt: Make sure device runtime resume completes before taking domain lock 2019-06-12 13:30:46 +03:00
tb_msgs.h thunderbolt: Add support for Intel Ice Lake 2019-08-26 12:15:06 +03:00
tb_regs.h thunderbolt: Add support for DMA tunnels 2019-04-18 11:18:53 +03:00
tunnel.c thunderbolt: Correct path indices for PCIe tunnel 2019-08-26 12:08:57 +03:00
tunnel.h thunderbolt: Add support for DMA tunnels 2019-04-18 11:18:53 +03:00
xdomain.c thunderbolt: Fix memory leak if ida_simple_get() fails in enumerate_services() 2020-11-18 19:20:29 +01:00