* [PATCH] Bluetooth: hci_core: Fix queuing tx_work after workqueue is drained
@ 2026-09-06 15:21 ThangNN99
2026-09-06 17:02 ` bluez.test.bot
2026-09-08 16:30 ` [PATCH] " patchwork-bot+bluetooth
0 siblings, 2 replies; 3+ messages in thread
From: ThangNN99 @ 2026-09-06 15:21 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz
Cc: linux-bluetooth, linux-kernel, ThangNN99,
syzbot+b6919040d9958e2fc1ae
hci_send_acl(), hci_send_sco() and hci_send_iso() queue hdev->tx_work
unconditionally. They can run from the L2CAP/SCO/ISO socket send path
while hci_dev_close_sync() is draining hdev->workqueue (HCIDEVDOWN
racing with a socket write). Since that queue_work() is not chained
work from the tx_work worker itself, __queue_work() sees the queue
marked __WQ_DRAINING, warns "cannot queue %ps on wq %s", and drops
the work:
WARNING: CPU: 1 PID: 5985 at kernel/workqueue.c:2352 __queue_work
Call Trace:
queue_work_on
l2cap_chan_send
l2cap_sock_sendmsg
...
hci_dev_close_sync() already sets HCI_CMD_DRAIN_WORKQUEUE before
draining, but only hci_cmd_work() and handle_cmd_cnt_and_timer()
check it before queuing. Route the tx_work producers through the
same guard via a shared hci_sched_tx() helper.
Fixes: 525daaea459f ("Bluetooth: hci_sync: Set HCI_CMD_DRAIN_WORKQUEUE during device close")
Reported-by: syzbot+b6919040d9958e2fc1ae@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=b6919040d9958e2fc1ae
Signed-off-by: ThangNN99 <ngocthang2710.1999@gmail.com>
---
net/bluetooth/hci_core.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 35a1be57e386..09cd49b9a939 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3236,6 +3236,17 @@ static void hci_queue_acl(struct hci_chan *chan, struct sk_buff_head *queue,
bt_dev_dbg(hdev, "chan %p queued %d", chan, skb_queue_len(queue));
}
+/* Queue hdev->tx_work, unless hdev->workqueue is being drained by
+ * hci_dev_close_sync(), which would otherwise WARN and drop the work.
+ */
+static void hci_sched_tx(struct hci_dev *hdev)
+{
+ rcu_read_lock();
+ if (!hci_dev_test_flag(hdev, HCI_CMD_DRAIN_WORKQUEUE))
+ queue_work(hdev->workqueue, &hdev->tx_work);
+ rcu_read_unlock();
+}
+
void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags)
{
struct hci_dev *hdev = chan->conn->hdev;
@@ -3244,7 +3255,7 @@ void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags)
hci_queue_acl(chan, &chan->data_q, skb, flags);
- queue_work(hdev->workqueue, &hdev->tx_work);
+ hci_sched_tx(hdev);
}
/* Send SCO data */
@@ -3269,7 +3280,7 @@ void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb)
bt_dev_dbg(hdev, "hcon %p queued %d", conn,
skb_queue_len(&conn->data_q));
- queue_work(hdev->workqueue, &hdev->tx_work);
+ hci_sched_tx(hdev);
}
/* Send ISO data */
@@ -3340,7 +3351,7 @@ void hci_send_iso(struct hci_conn *conn, struct sk_buff *skb)
hci_queue_iso(conn, &conn->data_q, skb);
- queue_work(hdev->workqueue, &hdev->tx_work);
+ hci_sched_tx(hdev);
}
/* ---- HCI TX task (outgoing data) ---- */
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: Bluetooth: hci_core: Fix queuing tx_work after workqueue is drained
2026-09-06 15:21 [PATCH] Bluetooth: hci_core: Fix queuing tx_work after workqueue is drained ThangNN99
@ 2026-09-06 17:02 ` bluez.test.bot
2026-09-08 16:30 ` [PATCH] " patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-09-06 17:02 UTC (permalink / raw)
To: linux-bluetooth, ngocthang2710.1999
[-- Attachment #1: Type: text/plain, Size: 2390 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1159088
---Test result---
Test Summary:
CheckPatch PASS 1.03 seconds
VerifyFixes PASS 0.12 seconds
VerifySignedoff PASS 0.12 seconds
GitLint PASS 0.31 seconds
SubjectPrefix PASS 0.12 seconds
BuildKernel PASS 28.46 seconds
CheckAllWarning PASS 30.93 seconds
CheckSparse PASS 29.82 seconds
BuildKernel32 PASS 27.39 seconds
CheckKernelLLVM SKIP 0.00 seconds
TestRunnerSetup PASS 517.56 seconds
TestRunner_l2cap-tester PASS 66.45 seconds
TestRunner_iso-tester PASS 113.75 seconds
TestRunner_bnep-tester PASS 19.69 seconds
TestRunner_mgmt-tester FAIL 228.20 seconds
TestRunner_rfcomm-tester PASS 26.65 seconds
TestRunner_sco-tester PASS 33.12 seconds
TestRunner_ioctl-tester PASS 27.29 seconds
TestRunner_mesh-tester FAIL 27.60 seconds
TestRunner_smp-tester PASS 23.95 seconds
TestRunner_userchan-tester PASS 20.56 seconds
TestRunner_6lowpan-tester PASS 23.93 seconds
IncrementalBuild PASS 26.98 seconds
Details
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis
Output:
Clang not found
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 501, Passed: 496 (99.0%), Failed: 1, Not Run: 4
Failed Test Cases
Read Exp Feature - Success Failed 0.253 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 1 Timed out 2.622 seconds
Mesh - Send cancel - 2 Timed out 1.947 seconds
https://github.com/bluez/bluetooth-next/pull/711
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Bluetooth: hci_core: Fix queuing tx_work after workqueue is drained
2026-09-06 15:21 [PATCH] Bluetooth: hci_core: Fix queuing tx_work after workqueue is drained ThangNN99
2026-09-06 17:02 ` bluez.test.bot
@ 2026-09-08 16:30 ` patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2026-09-08 16:30 UTC (permalink / raw)
To: ThangNN99
Cc: marcel, luiz.dentz, linux-bluetooth, linux-kernel,
syzbot+b6919040d9958e2fc1ae
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Sun, 6 Sep 2026 22:21:27 +0700 you wrote:
> hci_send_acl(), hci_send_sco() and hci_send_iso() queue hdev->tx_work
> unconditionally. They can run from the L2CAP/SCO/ISO socket send path
> while hci_dev_close_sync() is draining hdev->workqueue (HCIDEVDOWN
> racing with a socket write). Since that queue_work() is not chained
> work from the tx_work worker itself, __queue_work() sees the queue
> marked __WQ_DRAINING, warns "cannot queue %ps on wq %s", and drops
> the work:
>
> [...]
Here is the summary with links:
- Bluetooth: hci_core: Fix queuing tx_work after workqueue is drained
https://git.kernel.org/bluetooth/bluetooth-next/c/0010ea1bd14d
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-08 16:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-06 15:21 [PATCH] Bluetooth: hci_core: Fix queuing tx_work after workqueue is drained ThangNN99
2026-09-06 17:02 ` bluez.test.bot
2026-09-08 16:30 ` [PATCH] " 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