Re: [syzbot] [bluetooth?] KASAN: invalid-free in hci_req_sync_complete

Edward Adam Davis
2024-06-23T03:42:34Z

please test db free in hci_req_sync_complete

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2ccbdf43d5e7

diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index efea25eb56ce..c98d573eae87 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -106,7 +106,13 @@ void hci_req_sync_complete(struct hci_dev *hdev, u8 result, u16 opcode,
hdev->req_result = result;
hdev->req_status = HCI_REQ_DONE;
if (skb) {
- kfree_skb(hdev->req_skb);
+ if (!hdev->req_skb)
+ printk("skb: %p, fclone: %d %s\n", skb, skb->fclone, __func__);
+
+ if (hdev->req_skb && hdev->req_skb->fclone == SKB_FCLONE_CLONE) {
+ printk("skb: %p, skb fc: %d, rskb: %p, rskb fc: %d, %s\n", skb, skb->fclone, hdev->req_skb, hdev->req_skb->fclone, __func__);
+ kfree_skb(hdev->req_skb);
+ }
hdev->req_skb = skb_get(skb);
}
wake_up_interruptible(&hdev->req_wait_q);