From: Jeremy Dean Clifton <deaner92@yahoo.com>
To: marcel@holtmann.org, luiz.dentz@gmail.com
Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
william.xuanziyang@huawei.com, johan.hedberg@intel.com,
hdanton@sina.com, Jeremy Dean Clifton <deaner92@yahoo.com>,
syzbot+5897b3c764f5989ea942@syzkaller.appspotmail.com
Subject: [PATCH v2 3/3] Bluetooth: hci_sync: Disable connection works before draining
Date: Tue, 17 Nov 2026 02:33:44 +0000 [thread overview]
Message-ID: <20261117023344.278269-4-deaner92@yahoo.com> (raw)
In-Reply-To: <20261117023344.278269-1-deaner92@yahoo.com>
A connection delayed work whose timer was armed before
hci_dev_close_sync() can expire while drain_workqueue() runs.
delayed_work_timer_fn() then queues it on the draining workqueue and
triggers the "cannot queue ... on wq" warning. hci_conn_drop() can also
queue disc_work from another context during the drain.
Disable the per-connection delayed works under hdev->lock before
draining. A disabled work is cancelled and any later attempt to queue
it fails, so neither the timers nor hci_conn_drop() can queue it. The
connections are deleted by hci_conn_hash_flush() below, so nothing
needs to re-enable the works.
Fixes: 76727c02c1e1 ("Bluetooth: Call drain_workqueue() before resetting state")
Reported-by: syzbot+5897b3c764f5989ea942@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=5897b3c764f5989ea942
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jeremy Dean Clifton <deaner92@yahoo.com>
---
net/bluetooth/hci_sync.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 931494348325..3fe179d649d0 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -6012,6 +6012,7 @@ static int hci_dev_shutdown(struct hci_dev *hdev)
int hci_dev_close_sync(struct hci_dev *hdev)
{
+ struct hci_conn *conn;
bool auto_off;
int err = 0;
@@ -6079,6 +6080,22 @@ int hci_dev_close_sync(struct hci_dev *hdev)
cancel_delayed_work_sync(&adv_instance->rpa_expired_cb);
}
+ /* A delayed work whose timer was armed before close would queue
+ * itself while the workqueue is draining. Disable the connection
+ * works so that hci_conn_drop() and the timers can no longer queue
+ * them. The connections are deleted below, so nothing re-enables
+ * them. HCI_UP is clear, so no new connection can be added after
+ * this walk.
+ */
+ hci_dev_lock(hdev);
+ list_for_each_entry(conn, &hdev->conn_hash.list, list) {
+ disable_delayed_work(&conn->disc_work);
+ disable_delayed_work(&conn->auto_accept_work);
+ disable_delayed_work(&conn->idle_work);
+ disable_delayed_work(&conn->le_conn_timeout);
+ }
+ hci_dev_unlock(hdev);
+
/* Avoid potential lockdep warnings from the *_flush() calls by
* ensuring the workqueue is empty up front.
*/
--
2.43.0
prev parent reply other threads:[~2026-11-17 2:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261117023344.278269-1-deaner92.ref@yahoo.com>
2026-11-17 2:33 ` [PATCH v2 0/3] Bluetooth: Fix work queued while hci_dev_close_sync() drains Jeremy Dean Clifton
2026-11-17 2:33 ` [PATCH v2 1/3] Bluetooth: hci_conn: Free the unset handle when adding a connection fails Jeremy Dean Clifton
2026-11-17 2:33 ` [PATCH v2 2/3] Bluetooth: hci_conn: Refuse new connections once HCI_UP is cleared Jeremy Dean Clifton
2026-11-17 2:33 ` Jeremy Dean Clifton [this message]
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=20261117023344.278269-4-deaner92@yahoo.com \
--to=deaner92@yahoo.com \
--cc=hdanton@sina.com \
--cc=johan.hedberg@intel.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=syzbot+5897b3c764f5989ea942@syzkaller.appspotmail.com \
--cc=william.xuanziyang@huawei.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®