linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: Bluetooth: ISO: Fix possible circular locking dependency
  2023-01-10 21:30 [PATCH] Bluetooth: ISO: Fix possible circular locking dependency Luiz Augusto von Dentz
@ 2023-01-10 21:57 ` bluez.test.bot
  0 siblings, 0 replies; 7+ messages in thread
From: bluez.test.bot @ 2023-01-10 21:57 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1420 bytes --]

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=710698

---Test result---

Test Summary:
CheckPatch                    PASS      0.90 seconds
GitLint                       PASS      0.32 seconds
SubjectPrefix                 PASS      0.09 seconds
BuildKernel                   PASS      31.83 seconds
CheckAllWarning               PASS      35.21 seconds
CheckSparse                   PASS      39.26 seconds
CheckSmatch                   PASS      107.05 seconds
BuildKernel32                 PASS      30.59 seconds
TestRunnerSetup               PASS      441.39 seconds
TestRunner_l2cap-tester       PASS      16.59 seconds
TestRunner_iso-tester         PASS      17.17 seconds
TestRunner_bnep-tester        PASS      5.83 seconds
TestRunner_mgmt-tester        PASS      111.56 seconds
TestRunner_rfcomm-tester      PASS      9.17 seconds
TestRunner_sco-tester         PASS      8.40 seconds
TestRunner_ioctl-tester       PASS      9.85 seconds
TestRunner_mesh-tester        PASS      7.22 seconds
TestRunner_smp-tester         PASS      8.31 seconds
TestRunner_userchan-tester    PASS      6.11 seconds
IncrementalBuild              PASS      29.04 seconds



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Bluetooth: hci_event: Fix Invalid wait context
@ 2023-01-11  1:22 Luiz Augusto von Dentz
  2023-01-11  1:22 ` [PATCH] Bluetooth: ISO: Fix possible circular locking dependency Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2023-01-11  1:22 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

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

Fixes: 26afbd826ee3 ("Bluetooth: Add initial implementation of CIS connections")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 net/bluetooth/hci_event.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 0594af4e37ca..ad92a4be5851 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -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;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] Bluetooth: ISO: Fix possible circular locking dependency
  2023-01-11  1:22 [PATCH] Bluetooth: hci_event: Fix Invalid wait context Luiz Augusto von Dentz
@ 2023-01-11  1:22 ` Luiz Augusto von Dentz
  2023-01-11  2:37   ` bluez.test.bot
  2023-01-11 20:10   ` [PATCH] " patchwork-bot+bluetooth
  2023-01-11  2:41 ` Bluetooth: hci_event: Fix Invalid wait context bluez.test.bot
  2023-01-11 20:10 ` [PATCH] " patchwork-bot+bluetooth
  2 siblings, 2 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2023-01-11  1:22 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

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/0xcc

other 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

Fixes: f764a6c2c1e4 ("Bluetooth: ISO: Add broadcast support")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 net/bluetooth/iso.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c
index 6157bc12b373..24444b502e58 100644
--- a/net/bluetooth/iso.c
+++ b/net/bluetooth/iso.c
@@ -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;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: Bluetooth: ISO: Fix possible circular locking dependency
  2023-01-11  1:22 ` [PATCH] Bluetooth: ISO: Fix possible circular locking dependency Luiz Augusto von Dentz
@ 2023-01-11  2:37   ` bluez.test.bot
  2023-01-11 20:10   ` [PATCH] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 7+ messages in thread
From: bluez.test.bot @ 2023-01-11  2:37 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1420 bytes --]

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Bluetooth: hci_event: Fix Invalid wait context
  2023-01-11  1:22 [PATCH] Bluetooth: hci_event: Fix Invalid wait context Luiz Augusto von Dentz
  2023-01-11  1:22 ` [PATCH] Bluetooth: ISO: Fix possible circular locking dependency Luiz Augusto von Dentz
@ 2023-01-11  2:41 ` bluez.test.bot
  2023-01-11 20:10 ` [PATCH] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 7+ messages in thread
From: bluez.test.bot @ 2023-01-11  2:41 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1827 bytes --]

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Bluetooth: ISO: Fix possible circular locking dependency
  2023-01-11  1:22 ` [PATCH] Bluetooth: ISO: Fix possible circular locking dependency Luiz Augusto von Dentz
  2023-01-11  2:37   ` bluez.test.bot
@ 2023-01-11 20:10   ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 7+ messages in thread
From: patchwork-bot+bluetooth @ 2023-01-11 20:10 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue, 10 Jan 2023 17:22:54 -0800 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> 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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Bluetooth: hci_event: Fix Invalid wait context
  2023-01-11  1:22 [PATCH] Bluetooth: hci_event: Fix Invalid wait context Luiz Augusto von Dentz
  2023-01-11  1:22 ` [PATCH] Bluetooth: ISO: Fix possible circular locking dependency Luiz Augusto von Dentz
  2023-01-11  2:41 ` Bluetooth: hci_event: Fix Invalid wait context bluez.test.bot
@ 2023-01-11 20:10 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+bluetooth @ 2023-01-11 20:10 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue, 10 Jan 2023 17:22:53 -0800 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> 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
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-01-11 20:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-11  1:22 [PATCH] Bluetooth: hci_event: Fix Invalid wait context Luiz Augusto von Dentz
2023-01-11  1:22 ` [PATCH] Bluetooth: ISO: Fix possible circular locking dependency Luiz Augusto von Dentz
2023-01-11  2:37   ` bluez.test.bot
2023-01-11 20:10   ` [PATCH] " patchwork-bot+bluetooth
2023-01-11  2:41 ` Bluetooth: hci_event: Fix Invalid wait context bluez.test.bot
2023-01-11 20:10 ` [PATCH] " patchwork-bot+bluetooth
  -- strict thread matches above, loose matches on Subject: below --
2023-01-10 21:30 [PATCH] Bluetooth: ISO: Fix possible circular locking dependency Luiz Augusto von Dentz
2023-01-10 21:57 ` bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).