Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH v4] Bluetooth: hci_core: Fix UAF in hci_unregister_dev()
@ 2026-06-03  8:50 Jordan Walters
  2026-06-03 12:39 ` [v4] " bluez.test.bot
  2026-06-03 17:50 ` [PATCH v4] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Jordan Walters @ 2026-06-03  8:50 UTC (permalink / raw)
  To: linux-bluetooth, linux-kernel

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.

Signed-off-by: Jordan Walters <jaggyaur@gmail.com>
---
v4: v3 accidentally resent older fix using cancel_delayed_work_sync.
    This is the correct version using disable_delayed_work_sync.

 net/bluetooth/hci_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 28d7929dc59..1cbc666527c 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -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);
 
-- 
2.49.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-03 17:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03  8:50 [PATCH v4] Bluetooth: hci_core: Fix UAF in hci_unregister_dev() Jordan Walters
2026-06-03 12:39 ` [v4] " bluez.test.bot
2026-06-03 17:50 ` [PATCH v4] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox