OpenCloudOS-Kernel/drivers/thunderbolt
Mika Westerberg 440fba897c thunderbolt: Fix NULL pointer dereference in tb_port_update_credits()
commit d3d17e23d1a0d1f959b4fa55b35f1802d9c584fa upstream.

Olliver reported that his system crashes when plugging in Thunderbolt 1
device:

 BUG: kernel NULL pointer dereference, address: 0000000000000020
 #PF: supervisor read access in kernel mode
 #PF: error_code(0x0000) - not-present page
 PGD 0 P4D 0
 Oops: 0000 [#1] PREEMPT SMP NOPTI
 RIP: 0010:tb_port_do_update_credits+0x1b/0x130 [thunderbolt]
 Call Trace:
  <TASK>
  ? __die+0x23/0x70
  ? page_fault_oops+0x171/0x4e0
  ? exc_page_fault+0x7f/0x180
  ? asm_exc_page_fault+0x26/0x30
  ? tb_port_do_update_credits+0x1b/0x130
  ? tb_switch_update_link_attributes+0x83/0xd0
  tb_switch_add+0x7a2/0xfe0
  tb_scan_port+0x236/0x6f0
  tb_handle_hotplug+0x6db/0x900
  process_one_work+0x171/0x340
  worker_thread+0x27b/0x3a0
  ? __pfx_worker_thread+0x10/0x10
  kthread+0xe5/0x120
  ? __pfx_kthread+0x10/0x10
  ret_from_fork+0x31/0x50
  ? __pfx_kthread+0x10/0x10
  ret_from_fork_asm+0x1b/0x30
  </TASK>

This is due the fact that some Thunderbolt 1 devices only have one lane
adapter. Fix this by checking for the lane 1 before we read its credits.

Reported-by: Olliver Schinagl <oliver@schinagl.nl>
Closes: https://lore.kernel.org/linux-usb/c24c7882-6254-4e68-8f22-f3e8f65dc84f@schinagl.nl/
Fixes: 81af2952e606 ("thunderbolt: Add support for asymmetric link")
Cc: stable@vger.kernel.org
Cc: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-10-04 16:30:04 +02:00
..
Kconfig thunderbolt: Changes for v6.1 merge window 2022-09-30 13:44:59 +02:00
Makefile thunderbolt: Move CLx support functions into clx.c 2023-06-09 12:07:23 +03:00
acpi.c thunderbolt: Log a warning if device links are not found 2023-08-08 08:13:11 +03:00
cap.c
clx.c thunderbolt: Enable CL2 low power state 2023-06-16 09:53:28 +03:00
ctl.c thunderbolt: Add the new USB4 v2 notification types 2023-06-16 09:53:28 +03:00
ctl.h thunderbolt: Add support for DisplayPort bandwidth allocation mode 2023-01-17 11:37:16 +02:00
debugfs.c thunderbolt: debugfs: Fix margin debugfs node creation condition 2024-06-21 14:38:25 +02:00
dma_port.c
dma_port.h
dma_test.c thunderbolt: Add support for USB4 v2 80 Gb/s link 2023-06-16 09:53:27 +03:00
domain.c thunderbolt: Reset topology created by the boot firmware 2024-04-27 17:11:35 +02:00
eeprom.c thunderbolt: Ignore data CRC mismatch for USB4 routers 2023-06-16 09:53:27 +03:00
icm.c thunderbolt: Reset topology created by the boot firmware 2024-04-27 17:11:35 +02:00
lc.c thunderbolt: Introduce tb_port_reset() 2024-04-27 17:11:35 +02:00
nhi.c thunderbolt: Reset topology created by the boot firmware 2024-04-27 17:11:35 +02:00
nhi.h thunderbolt: Limit Intel Barlow Ridge USB3 bandwidth 2023-06-16 09:53:28 +03:00
nhi_ops.c
nhi_regs.h thunderbolt: Reset USB4 v2 host router 2023-06-16 09:53:28 +03:00
nvm.c thunderbolt: Increase NVM_MAX_SIZE to support Intel Barlow Ridge controller 2023-06-16 09:53:28 +03:00
path.c thunderbolt: Introduce tb_path_deactivate_hop() 2024-04-27 17:11:35 +02:00
property.c
quirks.c thunderbolt: Keep the domain powered when USB4 port is in redrive mode 2024-04-13 13:07:38 +02:00
retimer.c thunderbolt: Enable/disable sideband depending on USB4 port offline mode 2023-06-12 08:38:01 +03:00
sb_regs.h thunderbolt: Add missing UNSET_INBOUND_SBTX for retimer access 2023-03-13 11:54:20 +02:00
switch.c thunderbolt: Fix NULL pointer dereference in tb_port_update_credits() 2024-10-04 16:30:04 +02:00
tb.c thunderbolt: Improve DisplayPort tunnel setup process to be more robust 2024-10-04 16:30:01 +02:00
tb.h thunderbolt: Add support for asymmetric link 2024-10-04 16:30:01 +02:00
tb_msgs.h thunderbolt: Add the new USB4 v2 notification types 2023-06-16 09:53:28 +03:00
tb_regs.h thunderbolt: Add support for asymmetric link 2024-10-04 16:30:01 +02:00
test.c thunderbolt: Add test case for 3 DisplayPort tunnels 2023-06-16 09:53:29 +03:00
tmu.c thunderbolt: Correct TMU mode initialization from hardware 2023-09-15 12:59:02 +03:00
tunnel.c thunderbolt: Introduce tb_port_path_direction_downstream() 2024-10-04 16:30:01 +02:00
tunnel.h thunderbolt: Change bandwidth reservations to comply USB4 v2 2024-10-04 16:30:01 +02:00
usb4.c thunderbolt: Fix minimum allocated USB 3.x and PCIe bandwidth 2024-10-04 16:30:04 +02:00
usb4_port.c thunderbolt: Add wake on connect/disconnect on USB4 ports 2022-11-07 14:36:47 +02:00
xdomain.c thunderbolt: Restart XDomain discovery handshake after failure 2023-09-15 13:01:18 +03:00