Bluetooth: hci_event: Fix Invalid wait context
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH 1/1 Bluetooth: hci_event: Fix Invalid wait context
From: Luiz Augusto von Dentz <[email protected]>
This fixes the following trace caused by attempting to lock cmd_sync_work_lock while holding the rcu_read_lock:
kworker/u3:2/212 is trying to lock:ffff888002600910 (&hdev->cmd_sync_work_lock){+.+.}-{3:3}, at:hci_cmd_sync_queue+0xad/0x140
other info that might help us debug this:
context-{4:4}
4 locks held by kworker/u3:2/212:
#0: ffff8880028c6530 ((wq_completion)hci0#2){+.+.}-{0:0}, at:
process_one_work+0x4dc/0x9a0
#1: ffff888001aafde0 ((work_completion)(&hdev->rx_work)){+.+.}-{0:0},
at: process_one_work+0x4dc/0x9a0
#2: ffff888002600070 (&hdev->lock){+.+.}-{3:3}, at:
hci_cc_le_set_cig_params+0x64/0x4f0
#3: ffffffffa5994b00 (rcu_read_lock){....}-{1:2}, at:
hci_cc_le_set_cig_params+0x2f9/0x4f0--- net/bluetooth/hci_event.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/bluetooth/hci_event.c +4 -1
@@ -3848,8 +3848,11 @@ static u8 hci_cc_le_set_cig_params(struct hci_dev *hdev, void *data, conn->handle, conn->link);/* Create CIS if LE is already connected */ -if (conn->link && conn->link->state ==BT_CONNECTED ) +if (conn->link && conn->link->state ==BT_CONNECTED ) { +rcu_read_unlock ();hci_le_create_cis (conn->link); +rcu_read_lock (); + }if (i == rp->num_handles)break ;
Signature · 1 line
2.37.3
Luiz Augusto von Dentz
maintainerPATCH 1/1 Bluetooth: ISO: Fix possible circular locking dependency
From: Luiz Augusto von Dentz <[email protected]>
This attempts to fix the following trace:
iso-tester/52 is trying to acquire lock:ffff8880024e0070 (&hdev->lock){+.+.}-{3:3}, at:iso_sock_listen+0x29e/0x440
but task is already holding lock:ffff888001978130 (sk_lock-AF_BLUETOOTH-BTPROTO_ISO){+.+.}-{0:0}, at:iso_sock_listen+0x8b/0x440
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (sk_lock-AF_BLUETOOTH-BTPROTO_ISO){+.+.}-{0:0}:
lock_acquire+0x176/0x3d0
lock_sock_nested+0x32/0x80
iso_connect_cfm+0x1a3/0x630
hci_cc_le_setup_iso_path+0x195/0x340
hci_cmd_complete_evt+0x1ae/0x500
hci_event_packet+0x38e/0x7c0
hci_rx_work+0x34c/0x980
process_one_work+0x5a5/0x9a0
worker_thread+0x89/0x6f0
kthread+0x14e/0x180
ret_from_fork+0x22/0x30-> #1 (hci_cb_list_lock){+.+.}-{3:3}:
lock_acquire+0x176/0x3d0
__mutex_lock+0x13b/0xf50
hci_le_remote_feat_complete_evt+0x17e/0x320
hci_event_packet+0x38e/0x7c0
hci_rx_work+0x34c/0x980
process_one_work+0x5a5/0x9a0
worker_thread+0x89/0x6f0
kthread+0x14e/0x180
ret_from_fork+0x22/0x30-> #0 (&hdev->lock){+.+.}-{3:3}:
check_prev_add+0xfc/0x1190
__lock_acquire+0x1e27/0x2750
lock_acquire+0x176/0x3d0
__mutex_lock+0x13b/0xf50
iso_sock_listen+0x29e/0x440
__sys_listen+0xe6/0x160
__x64_sys_listen+0x25/0x30
do_syscall_64+0x42/0x90
entry_SYSCALL_64_after_hwframe+0x62/0xccother info that might help us debug this:
Chain exists of: &hdev->lock --> hci_cb_list_lock --> sk_lock-AF_BLUETOOTH-BTPROTO_ISO Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(sk_lock-AF_BLUETOOTH-BTPROTO_ISO);
lock(hci_cb_list_lock);
lock(sk_lock-AF_BLUETOOTH-BTPROTO_ISO); lock(&hdev->lock);
*** DEADLOCK ***
1 lock held by iso-tester/52:
#0: ffff888001978130 (sk_lock-AF_BLUETOOTH-BTPROTO_ISO){+.+.}-{0:0}, at:
iso_sock_listen+0x8b/0x440
--- net/bluetooth/iso.c | 3 --- 1 file changed, 3 deletions(-)
net/bluetooth/iso.c +0 -3
@@ -893,13 +893,10 @@ static int iso_listen_bis(struct sock *sk)if (!hdev)return -EHOSTUNREACH ; -hci_dev_lock (hdev); - err =hci_pa_create_sync (hdev, &iso_pi (sk)->dst,le_addr_type (iso_pi (sk)->dst_type),iso_pi (sk)->bc_sid); -hci_dev_unlock (hdev);hci_dev_put (hdev);return err;
Signature · 1 line
2.37.3
RE: Bluetooth: ISO: Fix possible circular locking dependency
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=710752
---Test result---
Test Summary:
CheckPatch PASS 0.68 seconds GitLint PASS 0.33 seconds SubjectPrefix PASS 0.12 seconds BuildKernel PASS 32.25 seconds CheckAllWarning PASS 34.92 seconds CheckSparse PASS 39.21 seconds CheckSmatch PASS 106.04 seconds BuildKernel32 PASS 30.40 seconds TestRunnerSetup PASS 438.76 seconds TestRunner_l2cap-tester PASS 16.56 seconds TestRunner_iso-tester PASS 17.06 seconds TestRunner_bnep-tester PASS 5.80 seconds TestRunner_mgmt-tester PASS 110.88 seconds TestRunner_rfcomm-tester PASS 9.18 seconds TestRunner_sco-tester PASS 8.42 seconds TestRunner_ioctl-tester PASS 9.76 seconds TestRunner_mesh-tester PASS 7.38 seconds TestRunner_smp-tester PASS 8.28 seconds TestRunner_userchan-tester PASS 6.06 seconds IncrementalBuild PASS 28.85 seconds
---
Regards,
Linux Bluetooth
Re: [PATCH] Bluetooth: ISO: Fix possible circular locking dependency
In reply to Luiz Augusto von DentzThis 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 9 lines · On Tue, 10 Jan 2023 17:22:54 -0800 you wrote:
From: Luiz Augusto von Dentz <[email protected]>
This attempts to fix the following trace:
iso-tester/52 is trying to acquire lock:
ffff8880024e0070(&hdev->lock){+.+.}-{3:3}, at:iso_sock_listen+0x29e/0x440[...]
Here is the summary with links:
- Bluetooth: ISO: Fix possible circular locking dependency
https://git.kernel.org/bluetooth/bluetooth-next/c/489691e98909
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
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=710751
---Test result---
Test Summary:
CheckPatch PASS 0.79 seconds GitLint PASS 0.23 seconds SubjectPrefix PASS 0.06 seconds BuildKernel PASS 38.57 seconds CheckAllWarning PASS 43.05 seconds CheckSparse WARNING 48.98 seconds CheckSmatch WARNING 128.74 seconds BuildKernel32 PASS 37.90 seconds TestRunnerSetup PASS 540.85 seconds TestRunner_l2cap-tester PASS 18.79 seconds TestRunner_iso-tester PASS 20.54 seconds TestRunner_bnep-tester PASS 6.58 seconds TestRunner_mgmt-tester PASS 128.52 seconds TestRunner_rfcomm-tester PASS 10.52 seconds TestRunner_sco-tester PASS 10.03 seconds TestRunner_ioctl-tester PASS 12.19 seconds TestRunner_mesh-tester PASS 8.28 seconds TestRunner_smp-tester PASS 9.58 seconds TestRunner_userchan-tester PASS 7.12 seconds IncrementalBuild PASS 35.88 seconds
Details
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
---
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 20 lines · On Tue, 10 Jan 2023 17:22:53 -0800 you wrote:
From: Luiz Augusto von Dentz <[email protected]>
This fixes the following trace caused by attempting to lock
cmd_sync_work_lockwhile holding thercu_read_lock:kworker/u3:2/212 is trying to lock:
ffff888002600910(&hdev->cmd_sync_work_lock){+.+.}-{3:3}, at:hci_cmd_sync_queue+0xad/0x140
other info that might help us debug this:
context-{4:4}
4 locks held by kworker/u3:2/212:
#0:ffff8880028c6530((wq_completion)hci0#2){+.+.}-{0:0}, at:process_one_work+0x4dc/0x9a0 #1: ffff888001aafde0 ((work_completion)(&hdev->rx_work)){+.+.}-{0:0}, at: process_one_work+0x4dc/0x9a0 #2: ffff888002600070 (&hdev->lock){+.+.}-{3:3}, at: hci_cc_le_set_cig_params+0x64/0x4f0 #3: ffffffffa5994b00 (rcu_read_lock){....}-{1:2}, at: hci_cc_le_set_cig_params+0x2f9/0x4f0
Quoted 1 line
[...]
Here is the summary with links:
- Bluetooth: hci_event: Fix Invalid wait context
https://git.kernel.org/bluetooth/bluetooth-next/c/fd18e1680ee2
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html