Luiz Augusto von Dentz
18fd04ad85
Bluetooth: hci_conn: Fix UAF in hci_enhanced_setup_sync
This checks if the ACL connection remains valid as it could be destroyed
while hci_enhanced_setup_sync is pending on cmd_sync leading to the
following trace:
BUG: KASAN: slab-use-after-free in hci_enhanced_setup_sync+0x91b/0xa60
Read of size 1 at addr ffff888002328ffd by task kworker/u5:2/37
CPU: 0 UID: 0 PID: 37 Comm: kworker/u5:2 Not tainted 6.11.0-rc6-01300-g810be445d8d6 #7099
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-2.fc40 04/01/2014
Workqueue: hci0 hci_cmd_sync_work
Call Trace:
<TASK>
dump_stack_lvl+0x5d/0x80
? hci_enhanced_setup_sync+0x91b/0xa60
print_report+0x152/0x4c0
? hci_enhanced_setup_sync+0x91b/0xa60
? __virt_addr_valid+0x1fa/0x420
? hci_enhanced_setup_sync+0x91b/0xa60
kasan_report+0xda/0x1b0
? hci_enhanced_setup_sync+0x91b/0xa60
hci_enhanced_setup_sync+0x91b/0xa60
? __pfx_hci_enhanced_setup_sync+0x10/0x10
? __pfx___mutex_lock+0x10/0x10
hci_cmd_sync_work+0x1c2/0x330
process_one_work+0x7d9/0x1360
? __pfx_lock_acquire+0x10/0x10
? __pfx_process_one_work+0x10/0x10
? assign_work+0x167/0x240
worker_thread+0x5b7/0xf60
? __kthread_parkme+0xac/0x1c0
? __pfx_worker_thread+0x10/0x10
? __pfx_worker_thread+0x10/0x10
kthread+0x293/0x360
? __pfx_kthread+0x10/0x10
ret_from_fork+0x2f/0x70
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1a/0x30
</TASK>
Allocated by task 34:
kasan_save_stack+0x30/0x50
kasan_save_track+0x14/0x30
__kasan_kmalloc+0x8f/0xa0
__hci_conn_add+0x187/0x17d0
hci_connect_sco+0x2e1/0xb90
sco_sock_connect+0x2a2/0xb80
__sys_connect+0x227/0x2a0
__x64_sys_connect+0x6d/0xb0
do_syscall_64+0x71/0x140
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Freed by task 37:
kasan_save_stack+0x30/0x50
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x101/0x160
kfree+0xd0/0x250
device_release+0x9a/0x210
kobject_put+0x151/0x280
hci_conn_del+0x448/0xbf0
hci_abort_conn_sync+0x46f/0x980
hci_cmd_sync_work+0x1c2/0x330
process_one_work+0x7d9/0x1360
worker_thread+0x5b7/0xf60
kthread+0x293/0x360
ret_from_fork+0x2f/0x70
ret_from_fork_asm+0x1a/0x30
Cc: stable@vger.kernel.org
Fixes: e07a06b4eb ("Bluetooth: Convert SCO configure_datapath to hci_sync")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2024-10-04 16:54:17 -04:00
..
2024-10-02 17:23:23 -04:00
2024-09-10 13:07:08 -04:00
2023-08-11 11:37:22 -07:00
2024-10-04 16:54:10 -04:00
2024-04-29 13:32:01 +01:00
2024-03-06 17:26:25 -05:00
2022-08-08 17:04:37 -07:00
2021-11-02 19:37:52 +01:00
2024-10-02 17:23:23 -04:00
2023-02-13 18:34:48 +08:00
2021-04-27 17:05:53 -07:00
2024-03-08 10:22:17 -05:00
2024-10-02 17:23:23 -04:00
2022-12-02 13:09:31 -08:00
2021-09-07 14:09:18 -07:00
2024-10-04 16:54:17 -04:00
2024-10-03 09:44:00 -07:00
2024-07-15 10:11:35 -04:00
2021-09-22 16:17:13 +02:00
2024-10-03 09:44:00 -07:00
2024-10-02 17:23:23 -04:00
2024-09-10 13:07:24 -04:00
2023-10-23 11:05:11 -07:00
2024-07-14 21:34:31 -04:00
2024-03-06 17:22:39 -05:00
2024-09-27 10:52:18 -04:00
2024-06-28 14:32:02 -04:00
2024-09-10 13:06:11 -04:00
2023-12-22 12:54:55 -05:00
2024-07-15 10:11:35 -04:00
2021-06-26 07:12:42 +02:00
2020-06-18 13:11:03 +03:00
2024-10-02 17:23:23 -04:00
2023-01-17 15:50:10 -08:00
2024-10-03 09:44:00 -07:00
2024-07-15 10:11:35 -04:00
2024-05-03 13:05:28 -04:00
2024-05-18 10:32:39 -07:00
2021-03-13 00:04:03 +11:00
2024-08-30 17:56:53 -04:00
2021-06-26 07:12:37 +02:00