Bluetooth: L2CAP: Fix deadlock in l2cap_conn_del()
Subsystems (2)
PATCH v2 1/1 Bluetooth: L2CAP: Fix deadlock in l2cap_conn_del()
l2cap_conn_del() calls cancel_delayed_work_sync() for both info_timer and id_addr_timer while holding conn->lock. However, the work functions l2cap_info_timeout() and l2cap_conn_update_id_addr() both acquire conn->lock, creating a potential AB-BA deadlock if the work is already executing when l2cap_conn_del() takes the lock.
Move the work cancellations before acquiring conn->lock and use disable_delayed_work_sync() to additionally prevent the works from being rearmed after cancellation, consistent with the pattern used in hci_conn_del().
---
Changes in v2:
- Replace cancel_delayed_work_sync() with disable_delayed_work_sync()
- v1: https://lore.kernel.org/all/abwTQVhyDv0_x26G@v4bel/
--- net/bluetooth/l2cap_core.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
net/bluetooth/l2cap_core.c +3 -5
@@ -1748,6 +1748,9 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)BT_DBG ("hcon %p conn %p, err %d" , hcon, conn, err); +disable_delayed_work_sync (&conn->info_timer); +disable_delayed_work_sync (&conn->id_addr_timer); +mutex_lock (&conn->lock);kfree_skb (conn->rx_skb);
@@ -1763,8 +1766,6 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)ida_destroy (&conn->tx_ida); -cancel_delayed_work_sync (&conn->id_addr_timer); -l2cap_unregister_all_users (conn);/* Force the connection to be immediately dropped */
@@ -1783,9 +1784,6 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)l2cap_chan_put (chan); } -if (conn->info_state &L2CAP_INFO_FEAT_MASK_REQ_SENT ) -cancel_delayed_work_sync (&conn->info_timer); -hci_chan_del (conn->hchan); conn->hchan =NULL ;
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=1069844
---Test result---
Test Summary:
CheckPatch PENDING 0.36 seconds GitLint PENDING 0.29 seconds SubjectPrefix PASS 0.12 seconds BuildKernel PASS 26.71 seconds CheckAllWarning PASS 29.15 seconds CheckSparse PASS 28.09 seconds BuildKernel32 PASS 25.78 seconds TestRunnerSetup PASS 573.72 seconds TestRunner_l2cap-tester PASS 27.99 seconds TestRunner_iso-tester FAIL 36.79 seconds TestRunner_bnep-tester PASS 6.48 seconds TestRunner_mgmt-tester FAIL 115.17 seconds TestRunner_rfcomm-tester PASS 9.64 seconds TestRunner_sco-tester FAIL 14.54 seconds TestRunner_ioctl-tester PASS 10.48 seconds TestRunner_mesh-tester FAIL 12.65 seconds TestRunner_smp-tester PASS 8.74 seconds TestRunner_userchan-tester PASS 6.88 seconds IncrementalBuild PENDING 0.46 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
BUG: KASAN: slab-use-after-free in le_read_features_complete+0x7e/0x2b0
Total: 141, Passed: 141 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4
Failed Test Cases
Read Exp Feature - Success Failed 0.103 seconds
##############################
Test: TestRunner_sco-tester - FAIL
Desc: Run sco-tester with test-runner
Output:
WARNING: possible circular locking dependency detected
BUG: sleeping function called from invalid context at net/core/sock.c:3782
Total: 30, Passed: 30 (100.0%), Failed: 0, Not Run: 0
##############################
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.758 seconds Mesh - Send cancel - 2 Timed out 1.994 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 6 lines · On Fri, 20 Mar 2026 20:01:26 +0900 you wrote:
l2cap_conn_del()callscancel_delayed_work_sync()for bothinfo_timerandid_addr_timerwhile holdingconn->lock. However, the work functionsl2cap_info_timeout()andl2cap_conn_update_id_addr()both acquireconn->lock, creating a potential AB-BA deadlock if the work is already executing whenl2cap_conn_del()takes the lock.
Quoted 6 lines
Move the work cancellations before acquiring
conn->lockand usedisable_delayed_work_sync()to additionally prevent the works from being rearmed after cancellation, consistent with the pattern used inhci_conn_del().[...]
Here is the summary with links:
- [v2] Bluetooth: L2CAP: Fix deadlock in l2cap_conn_del()
https://git.kernel.org/bluetooth/bluetooth-next/c/f6bba07f059c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html