From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+f098d64cc684b8dbaf65@syzkaller.appspotmail.com
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [bluetooth?] [usb?] memory leak in __hci_cmd_sync_sk
Date: Fri, 21 Nov 2025 17:06:55 +0800 [thread overview]
Message-ID: <tencent_0F3D6D368096B4367C4A0274FF77B767F209@qq.com> (raw)
In-Reply-To: <691b301e.a70a0220.f6df1.0011.GAE@google.com>
#syz test
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 3418d7b964a1..34887a154700 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1466,7 +1466,7 @@ static void hci_cmd_timeout(struct work_struct *work)
if (hdev->req_skb) {
u16 opcode = hci_skb_opcode(hdev->req_skb);
- bt_dev_err(hdev, "command 0x%4.4x tx timeout", opcode);
+ bt_dev_err(hdev, "command 0x%4.4x skb: %p tx timeout hdev: %p", opcode, hdev->req_skb, hdev);
hci_cmd_sync_cancel_sync(hdev, ETIMEDOUT);
} else {
@@ -4162,7 +4162,11 @@ static void hci_cmd_work(struct work_struct *work)
/* Send queued commands */
if (atomic_read(&hdev->cmd_cnt)) {
+ unsigned long flags;
+
+ spin_lock_irqsave(&hdev->cmd_q.lock, flags);
skb = skb_dequeue(&hdev->cmd_q);
+ spin_unlock_irqrestore(&hdev->cmd_q.lock, flags);
if (!skb)
return;
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 6e76798ec786..c16ab9089b5b 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -133,6 +133,8 @@ static int hci_req_sync_run(struct hci_request *req)
return -ENODATA;
skb = skb_peek_tail(&req->cmd_q);
+ printk("status: %u, result: %u, skb: %p, %s\n",
+ hdev->req_status, hdev->req_result, skb, __func__);
bt_cb(skb)->hci.req_complete_skb = hci_cmd_sync_complete;
bt_cb(skb)->hci.req_flags |= HCI_REQ_SKB;
@@ -158,8 +160,9 @@ struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen,
struct sock *sk)
{
struct hci_request req;
- struct sk_buff *skb;
+ struct sk_buff *skb, *skb_tail;
int err = 0;
+ unsigned long flags;
bt_dev_dbg(hdev, "Opcode 0x%4.4x", opcode);
@@ -169,6 +172,7 @@ struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen,
hdev->req_status = HCI_REQ_PEND;
+ skb_tail = skb_peek_tail(&req.cmd_q);
err = hci_req_sync_run(&req);
if (err < 0)
return ERR_PTR(err);
@@ -201,18 +205,36 @@ struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen,
bt_dev_dbg(hdev, "end: err %d", err);
+ printk("err: %d, status: %u, result: %u, skb: %p, hdev: %p, %s\n",
+ err, hdev->req_status, hdev->req_result, skb, hdev, __func__);
if (err < 0) {
kfree_skb(skb);
- return ERR_PTR(err);
+ goto out;
}
/* If command return a status event skb will be set to NULL as there are
* no parameters.
*/
- if (!skb)
- return ERR_PTR(-ENODATA);
+ if (!skb) {
+ err = -ENODATA;
+ goto out;
+ }
return skb;
+
+out:
+ if (!skb_queue_empty(&hdev->cmd_q)) {
+ spin_lock_irqsave(&hdev->cmd_q.lock, flags);
+ skb = __skb_dequeue_tail(&hdev->cmd_q);
+ spin_unlock_irqrestore(&hdev->cmd_q.lock, flags);
+ skb_tail = NULL;
+ } else
+ skb = skb_tail;
+
+ printk("remove skb: %p, tskb: %p, hdev: %p, %s\n", skb, skb_tail, hdev, __func__);
+ kfree_skb(skb);
+
+ return ERR_PTR(err);
}
EXPORT_SYMBOL(__hci_cmd_sync_sk);
next prev parent reply other threads:[~2025-11-21 9:08 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 14:24 syzbot
2025-11-18 2:53 ` Edward Adam Davis
2025-11-18 3:24 ` syzbot
2025-11-18 3:40 ` Edward Adam Davis
2025-11-18 3:54 ` syzbot
2025-11-18 3:56 ` Edward Adam Davis
2025-11-18 4:24 ` syzbot
2025-11-19 2:46 ` shaurya
2025-11-19 3:22 ` Edward Adam Davis
2025-11-19 3:47 ` syzbot
2025-11-19 18:45 ` shaurya
2025-11-19 19:32 ` syzbot
2025-11-20 13:27 ` Edward Adam Davis
2025-11-20 13:59 ` syzbot
2025-11-20 14:11 ` Edward Adam Davis
2025-11-20 14:45 ` syzbot
2025-11-20 14:54 ` Edward Adam Davis
2025-11-20 15:27 ` syzbot
2025-11-21 0:05 ` Edward Adam Davis
2025-11-21 0:34 ` syzbot
2025-11-21 0:55 ` Edward Adam Davis
2025-11-21 2:14 ` syzbot
2025-11-21 0:57 ` Edward Adam Davis
2025-11-21 2:32 ` syzbot
2025-11-21 6:17 ` Edward Adam Davis
2025-11-21 8:08 ` syzbot
2025-11-21 9:06 ` Edward Adam Davis [this message]
2025-11-21 14:36 ` syzbot
2025-11-22 7:09 ` Edward Adam Davis
2025-11-22 10:23 ` syzbot
2025-11-22 14:14 ` Edward Adam Davis
2025-11-22 14:39 ` syzbot
2025-11-23 14:05 ` Edward Adam Davis
2025-11-23 15:23 ` syzbot
2025-11-23 14:33 ` Edward Adam Davis
2025-11-23 16:09 ` syzbot
2025-11-23 15:08 ` Edward Adam Davis
2025-11-23 16:30 ` syzbot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_0F3D6D368096B4367C4A0274FF77B767F209@qq.com \
--to=eadavis@qq.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+f098d64cc684b8dbaf65@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®