Re: [syzbot] [bluetooth?] KASAN: slab-use-after-free Read in set_powered_sync
From: Qianqiang Liu
Date: Thu Oct 03 2024 - 11:43:19 EST
#syz test
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 5533e6f561b3..353fa423c36c 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -321,7 +321,7 @@ static void hci_cmd_sync_work(struct work_struct *work)
bt_dev_dbg(hdev, "entry %p", entry);
- if (entry->func) {
+ if (entry->func && entry->data) {
int err;
hci_req_sync_lock(hdev);
diff --git a/net/bluetooth/mgmt_util.c b/net/bluetooth/mgmt_util.c
index 0115f783bde8..eccc51bfaf2e 100644
--- a/net/bluetooth/mgmt_util.c
+++ b/net/bluetooth/mgmt_util.c
@@ -307,6 +307,7 @@ void mgmt_pending_free(struct mgmt_pending_cmd *cmd)
sock_put(cmd->sk);
kfree(cmd->param);
kfree(cmd);
+ cmd = NULL;
}
void mgmt_pending_remove(struct mgmt_pending_cmd *cmd)
--
Best,
Qianqiang Liu