Bluetooth: hci_sync: wait for directed advertising completion
Subsystems (3)
PATCH v4 1/1 Bluetooth: hci_sync: wait for directed advertising completion
le_conn_timeout is embedded in struct hci_conn, but queuing the work does not hold a reference to the connection. hci_conn_del() uses cancel_delayed_work() because synchronous cancellation would deadlock when le_conn_timeout() itself calls hci_conn_del() while holding hdev->lock.
This leaves the following interleaving possible:
CPU 0 CPU 1
le_conn_timeout()
hci_conn_del()
cancel_delayed_work() = false hci_conn_cleanup()
put_device()
kfree(conn)
hci_conn_failed(conn, ...)
The callback then dereferences the released connection. KASAN reported:
BUG: KASAN: slab-use-after-free in hci_conn_failed+0x232/0x250 Read of size 8 at addr ffff8881180e8e20 by task kworker/u33:1/111 Workqueue: hci0 le_conn_timeout Call Trace: hci_conn_failed+0x232/0x250 le_conn_timeout+0x23e/0x2c0 process_one_work+0x61b/0xf50 worker_thread+0x45b/0xd10
Remove le_conn_timeout instead of adding another connection reference. Have the legacy and extended directed-advertising enable commands wait for the appropriate LE Connection Complete event in hci_le_create_conn_sync(). The command-sync entry already holds a connection reference until its completion callback returns.
Command Status already keeps a command-sync request pending when the command succeeds and a later event was requested. Do the same for Command Complete so controllers that complete LE Set Advertising Enable with Command Complete do not bypass the requested LE Connection Complete wait.
Mark directed advertising as an in-flight connection attempt so teardown can cancel the wait. Disable advertising synchronously when that wait fails, and preserve HCI_ERROR_ADVERTISING_TIMEOUT for a software timeout. Clear the instance-0 extended advertising state when advertising is stopped or a connection completes so resuming paused advertising does not restart the directed advertising instance.
There is then no delayed callback that can race with connection deletion.
---
Changes in v4:
- Rebase onto bluetooth-next/master so the patch applies to current Bluetooth CI HEAD.
Changes in v3:
- Keep command-sync requests pending on successful Command Complete when the caller requested a later event, matching the existing Command Status behavior and fixing the first Sashiko/Luiz report.
- Clear HCI_LE_ADV_0 when all extended advertising instances are disabled and when LE connection complete implicitly stops advertising, fixing the second Sashiko report about resuming stale directed advertising.
Changes in v2:
- Remove le_conn_timeout instead of adding references around delayed work.
- Wait for LE Connection Complete from both directed-advertising enable paths.
- Make the wait cancellable and disable advertising after a failed wait.
include/net/bluetooth/hci_core.h | 1 - net/bluetooth/hci_conn.c | 45 ------------------------------ net/bluetooth/hci_event.c | 47 +++++++++++--------------------- net/bluetooth/hci_sync.c | 42 ++++++++++++++++++++-------- 4 files changed, 46 insertions(+), 89 deletions(-)
include/net/bluetooth/hci_core.h +0 -1
@@ -769,7 +769,6 @@ struct hci_conn {struct delayed_work disc_work;struct delayed_work auto_accept_work;struct delayed_work idle_work; -struct delayed_work le_conn_timeout;struct device dev;struct dentry *debugfs;
net/bluetooth/hci_conn.c +0 -45
63 lines not on this page · raw message
net/bluetooth/hci_event.c +16 -31
94 lines not on this page · raw message
net/bluetooth/hci_sync.c +30 -12
84 lines not on this page · raw message
Signature · 1 line
2.43.0
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=1149955
---Test result---
Test Summary:
CheckPatch PASS 1.08 seconds VerifyFixes PASS 0.09 seconds VerifySignedoff PASS 0.09 seconds GitLint PASS 0.22 seconds SubjectPrefix PASS 0.08 seconds BuildKernel PASS 20.72 seconds CheckAllWarning PASS 22.44 seconds CheckSparse PASS 21.36 seconds BuildKernel32 PASS 20.27 seconds CheckKernelLLVM SKIP 0.00 seconds TestRunnerSetup PASS 366.74 seconds TestRunner_l2cap-tester PASS 52.34 seconds TestRunner_iso-tester FAIL 73.59 seconds TestRunner_bnep-tester PASS 14.91 seconds TestRunner_mgmt-tester FAIL 180.28 seconds TestRunner_rfcomm-tester PASS 19.78 seconds TestRunner_sco-tester PASS 25.55 seconds TestRunner_ioctl-tester PASS 21.03 seconds TestRunner_mesh-tester FAIL 21.54 seconds TestRunner_smp-tester PASS 18.33 seconds TestRunner_userchan-tester PASS 15.47 seconds TestRunner_6lowpan-tester PASS 18.20 seconds IncrementalBuild PASS 19.11 seconds
Details
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis Output:
Clang not found
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
Total: 141, Passed: 136 (96.5%), Failed: 5, Not Run: 0
Failed Test Cases
ISO Broadcaster PAST Info - Success Timed out 2.777 seconds ISO Broadcaster PAST Info RPA - Success Timed out 2.004 seconds ISO Broadcaster PAST Sender - Success Timed out 1.990 seconds ISO Broadcaster PAST Receiver - Success Timed out 2.107 seconds ISO Broadcaster PAST Receiver Sync Lost - Success Timed out 2.111 seconds
##############################
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.196 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.666 seconds Mesh - Send cancel - 2 Timed out 1.990 seconds
https://github.com/bluez/bluetooth-next/pull/629
---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz
maintainerHi,
Quoted 48 lines · On Fri, Aug 21, 2026 at 2:00 PM <[email protected]> wrote:
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=1149955---Test result---
Test Summary:
CheckPatch PASS 1.08 seconds VerifyFixes PASS 0.09 seconds VerifySignedoff PASS 0.09 seconds GitLint PASS 0.22 seconds SubjectPrefix PASS 0.08 seconds BuildKernel PASS 20.72 seconds CheckAllWarning PASS 22.44 seconds CheckSparse PASS 21.36 seconds BuildKernel32 PASS 20.27 seconds CheckKernelLLVM SKIP 0.00 seconds TestRunnerSetup PASS 366.74 seconds TestRunner_l2cap-tester PASS 52.34 seconds TestRunner_iso-tester FAIL 73.59 seconds TestRunner_bnep-tester PASS 14.91 seconds TestRunner_mgmt-tester FAIL 180.28 seconds TestRunner_rfcomm-tester PASS 19.78 seconds TestRunner_sco-tester PASS 25.55 seconds TestRunner_ioctl-tester PASS 21.03 seconds TestRunner_mesh-tester FAIL 21.54 seconds TestRunner_smp-tester PASS 18.33 seconds TestRunner_userchan-tester PASS 15.47 seconds TestRunner_6lowpan-tester PASS 18.20 seconds IncrementalBuild PASS 19.11 secondsDetails
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis Output:
Clang not found
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
Total: 141, Passed: 136 (96.5%), Failed: 5, Not Run: 0
Quoted 6 lines
Failed Test Cases
ISO Broadcaster PAST Info - Success Timed out 2.777 seconds ISO Broadcaster PAST Info RPA - Success Timed out 2.004 seconds ISO Broadcaster PAST Sender - Success Timed out 1.990 seconds ISO Broadcaster PAST Receiver - Success Timed out 2.107 seconds ISO Broadcaster PAST Receiver Sync Lost - Success Timed out 2.111 seconds
Seem like this is causing some regression with PAST.
Quoted 25 lines
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner Output:
Total: 501, Passed: 496 (99.0%), Failed: 1, Not Run: 4Failed Test Cases
Read Exp Feature - Success Failed 0.196 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0Failed Test Cases
Mesh - Send cancel - 1 Timed out 2.666 seconds Mesh - Send cancel - 2 Timed out 1.990 secondshttps://github.com/bluez/bluetooth-next/pull/629
---
Regards,
Linux Bluetooth
Signature · 1 line
Luiz Augusto von Dentz