Re: [syzbot] [bluetooth?] KASAN: slab-use-after-free Read in set_powered_sync

From: Qianqiang Liu
Date: Thu Oct 03 2024 - 10:29:10 EST


#syz test

diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 5533e6f561b3..259b18eb0b20 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -5187,8 +5187,11 @@ int hci_dev_close_sync(struct hci_dev *hdev)
auto_off = hci_dev_test_and_clear_flag(hdev, HCI_AUTO_OFF);

if (!auto_off && !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
- hci_dev_test_flag(hdev, HCI_MGMT))
+ hci_dev_test_flag(hdev, HCI_MGMT)) {
+ hci_req_sync_lock(hdev);
__mgmt_power_off(hdev);
+ hci_req_sync_unlock(hdev);
+ }

hci_inquiry_cache_flush(hdev);
hci_pend_le_actions_clear(hdev);

--
Best,
Qianqiang Liu