twx-linux/drivers/thunderbolt
Mika Westerberg 502843396e thunderbolt: Prevent use-after-free in resume from hibernate
Kenneth noticed that his laptop crashes randomly when resuming from
hibernate if there is device connected and display tunneled. I was able
to reproduce this as well with the following steps:

  1. Boot the system up, nothing connected.
  2. Connect Thunderbolt 4 dock to the host.
  3. Connect monitor to the Thunderbolt 4 dock.
  4. Verify that there is picture on the screen.
  5. Enter hibernate.
  6. Exit hibernate.
  7. Wait for the system to resume.

  Expectation: System resumes just fine, the connected monitor still
               shows screen.
  Actual result: There is crash during resume, screen is blank.

What happens is that during resume from hibernate we tear down any
existing tunnels created by the boot kernel and this ends up calling
tb_dp_dprx_stop() which calls tb_tunnel_put() dropping the reference
count to zero even though we never called tb_dp_dprx_start() for it (we
never do that for discovery). This makes the discovered DP tunnel memory
to be released and any access after that causes use-after-free and
possible crash.

Fix this so that we only stop DPRX flow if it has been started in the
first place.

Reported-by: Kenneth Crudup <kenny@panix.com>
Closes: https://lore.kernel.org/linux-usb/8e175721-806f-45d6-892a-bd3356af80c9@panix.com/
Cc: stable@vger.kernel.org
Fixes: d6d458d42e1e ("thunderbolt: Handle DisplayPort tunnel activation asynchronously")
Reviewed-by: Yehezkel Bernat <YehezkelShB@gmail.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2025-03-07 14:00:58 +02:00
..
acpi.c thunderbolt: Don't create device link from USB4 Host Interface to USB3 xHC host 2024-09-03 09:54:39 +02:00
cap.c
clx.c thunderbolt: Check for unplugged router in tb_switch_clx_disable() 2023-10-13 08:49:13 +03:00
ctl.c thunderbolt: Debug log an invalid config space reply just once 2025-01-03 11:50:08 +02:00
ctl.h thunderbolt: Drop doubled empty line from ctl.h 2025-01-03 11:50:07 +02:00
debugfs.c thunderbolt: Expose router DROM through debugfs 2025-01-05 10:35:03 +02:00
dma_port.c
dma_port.h
dma_test.c thunderbolt: dma_test: Use enum tb_link_width 2023-10-13 08:49:12 +03:00
domain.c driver core: have match() callback in struct bus_type take a const * 2024-07-03 15:16:54 +02:00
eeprom.c thunderbolt: Expose router DROM through debugfs 2025-01-05 10:35:03 +02:00
icm.c thunderbolt: Enable NVM upgrade support on Intel Maple Ridge 2024-04-08 07:47:38 +03:00
Kconfig thunderbolt: Add receiver lane margining support for retimers 2024-06-17 12:47:12 +03:00
lc.c thunderbolt: Introduce tb_port_reset() 2024-01-22 13:21:06 +02:00
Makefile thunderbolt: Add trace events support for the control channel 2024-02-26 09:12:24 +02:00
nhi_ops.c
nhi_regs.h thunderbolt: Reset USB4 v2 host router 2023-06-16 09:53:28 +03:00
nhi.c thunderbolt: Add support for Intel Panther Lake-M/P 2024-12-10 08:02:17 +02:00
nhi.h thunderbolt: Add support for Intel Panther Lake-M/P 2024-12-10 08:02:17 +02:00
nvm.c thunderbolt: Remove usage of the deprecated ida_simple_xx() API 2024-01-23 13:30:20 +02:00
path.c thunderbolt: Show path name in debug log when path is deactivated 2025-01-03 11:50:08 +02:00
property.c
quirks.c thunderbolt: Keep the domain powered when USB4 port is in redrive mode 2024-02-26 09:12:12 +02:00
retimer.c Merge 6.13-rc7 into driver-core-next 2025-01-13 06:40:34 +01:00
sb_regs.h thunderbolt: debugfs: Implement asymmetric lane margining 2024-11-01 07:55:38 +02:00
switch.c thunderbolt: Mark XDomain as unplugged when router is removed 2024-08-06 08:01:10 +03:00
tb_msgs.h thunderbolt: Get rid of TB_CFG_PKG_PREPARE_TO_SLEEP 2024-04-19 07:52:45 +03:00
tb_regs.h thunderbolt: Changes for v6.9 merge window 2024-03-02 20:14:03 +01:00
tb.c thunderbolt: Handle DisplayPort tunnel activation asynchronously 2025-01-03 11:50:09 +02:00
tb.h thunderbolt: Expose router DROM through debugfs 2025-01-05 10:35:03 +02:00
test.c thunderbolt: Handle DisplayPort tunnel activation asynchronously 2025-01-03 11:50:09 +02:00
tmu.c thunderbolt: Unwind TMU configuration if tb_switch_set_tmu_mode_params() fails 2023-12-14 08:07:44 +02:00
trace.h thunderbolt: Correct trace output of firmware connection manager packets 2024-04-29 07:47:54 +03:00
tunnel.c thunderbolt: Prevent use-after-free in resume from hibernate 2025-03-07 14:00:58 +02:00
tunnel.h thunderbolt: Prevent use-after-free in resume from hibernate 2025-03-07 14:00:58 +02:00
usb4_port.c thunderbolt: Constify the struct device_type usage 2024-02-26 09:15:49 +02:00
usb4.c USB / Thunderbolt (USB4) changes for 6.13-rc1 2024-11-29 11:19:31 -08:00
xdomain.c driver core: Constify API device_find_child() and adapt for various usages 2025-01-03 11:19:35 +01:00