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>
Subject: [PATCH v2 0/3] Bluetooth: Fix work queued while hci_dev_close_sync() drains
Date: Tue, 17 Nov 2026 02:33:41 +0000 [thread overview]
Message-ID: <20261117023344.278269-1-deaner92@yahoo.com> (raw)
In-Reply-To: 20261117023344.278269-1-deaner92.ref@yahoo.com
syzbot reports "workqueue: cannot queue hci_conn_timeout on wq hci0"
from hci_conn_drop() while hci_dev_close_sync() runs drain_workqueue().
v1 made hci_conn_drop() skip queueing disc_work while
HCI_CMD_DRAIN_WORKQUEUE is set. Sashiko pointed out that this misses
two cases: a connection delayed work whose timer was armed before close
can still fire during the drain, and a connection created after
hci_conn_hash_flush() is never deleted.
v2 drops the hci_conn_drop() change and fixes the cause instead:
- Patch 1 frees the unset handle when __hci_conn_add() fails. The
leak already exists on the -ECONNREFUSED and -ENOMEM paths, and
patch 2 adds another error return. Sashiko found it while
reviewing patch 2.
- Patch 2 makes __hci_conn_add() refuse new connections once HCI_UP
is cleared, and asserts that hdev->lock is held. I checked every
caller and all of them hold the lock.
- Patch 3 disables the per-connection delayed works before
drain_workqueue(), so neither the timers nor hci_conn_drop() can
queue them during the drain. It depends on patch 2: without it, a
connection added after the walk could still queue its works.
Testing: built on arm64 against bluetooth-next (da3cc02). With KASAN
and lockdep enabled, the syzbot C reproducer was run under QEMU/HVF
(2 vCPUs), one fresh boot per run:
without this series: 7/12 runs hit "workqueue: cannot queue
hci_conn_timeout on wq hci0"
with this series: 0/12 runs, no other warnings, KASAN or
lockdep reports
Sashiko reviewed the series locally with no critical, high or medium
findings.
Claude (Opus 5.5) helped analyze the race, draft the patches and audit
the __hci_conn_add() callers for hdev->lock. Sashiko reviewed v1 and
this series.
Changes in v2:
- Drop the hci_conn_drop() change.
- Add patches 1 and 2.
- Disable the connection works before the drain (patch 3).
- Fixes tag changed from 525daaea459f to 76727c02c1e1.
v1: https://lore.kernel.org/all/20261020145320.115333-1-deaner92@yahoo.com/
Jeremy Dean Clifton (3):
Bluetooth: hci_conn: Free the unset handle when adding a connection
fails
Bluetooth: hci_conn: Refuse new connections once HCI_UP is cleared
Bluetooth: hci_sync: Disable connection works before draining
net/bluetooth/hci_conn.c | 16 +++++++++++++++-
net/bluetooth/hci_sync.c | 17 +++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
--
2.43.0
next parent reply other threads:[~2026-11-17 2:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261117023344.278269-1-deaner92.ref@yahoo.com>
2026-11-17 2:33 ` Jeremy Dean Clifton [this message]
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 11:23 ` Bluetooth: Fix work queued while hci_dev_close_sync() drains bluez.test.bot
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 ` [PATCH v2 3/3] Bluetooth: hci_sync: Disable connection works before draining Jeremy Dean Clifton
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-1-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=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