]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Bluetooth: hci_core: Fix UAF in hci_unregister_dev()
authorJordan Walters <jaggyaur@gmail.com>
Wed, 3 Jun 2026 08:50:47 +0000 (04:50 -0400)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 11 Jun 2026 18:24:40 +0000 (14:24 -0400)
hci_unregister_dev() does not disable cmd_timer and ncmd_timer
before the hci_dev structure is freed. If a timeout fires
during device teardown, the callback dereferences freed memory
(including the hdev->reset function pointer), leading to a
use-after-free.

Add disable_delayed_work_sync() calls alongside the existing
disable_work_sync() calls to ensure both timers are fully
quiesced before teardown proceeds.

Fixes: 0d151a103775 ("Bluetooth: hci_core: cancel all works upon hci_unregister_dev()")
Signed-off-by: Jordan Walters <jaggyaur@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/hci_core.c

index 28d7929dc593778913cfa6273da279f3f1f49e35..1cbc666527c57c68757fe93c3d3b1548c1aed3bf 100644 (file)
@@ -2671,6 +2671,8 @@ void hci_unregister_dev(struct hci_dev *hdev)
        disable_work_sync(&hdev->tx_work);
        disable_work_sync(&hdev->power_on);
        disable_work_sync(&hdev->error_reset);
+       disable_delayed_work_sync(&hdev->cmd_timer);
+       disable_delayed_work_sync(&hdev->ncmd_timer);
 
        hci_cmd_sync_clear(hdev);