Skip to content

Commit a0a2dc1

Browse files
author
Bastien Nocera
committed
Bluetooth: iso: Fix recursive locking warning
JIRA: https://issues.redhat.com/browse/RHEL-74483 commit 9bde7c3 Author: Iulia Tanasescu <[email protected]> Date: Wed Dec 4 14:28:49 2024 +0200 Bluetooth: iso: Fix recursive locking warning This updates iso_sock_accept to use nested locking for the parent socket, to avoid lockdep warnings caused because the parent and child sockets are locked by the same thread: [ 41.585683] ============================================ [ 41.585688] WARNING: possible recursive locking detected [ 41.585694] 6.12.0-rc6+ #22 Not tainted [ 41.585701] -------------------------------------------- [ 41.585705] iso-tester/3139 is trying to acquire lock: [ 41.585711] ffff988b29530a58 (sk_lock-AF_BLUETOOTH) at: bt_accept_dequeue+0xe3/0x280 [bluetooth] [ 41.585905] but task is already holding lock: [ 41.585909] ffff988b29533a58 (sk_lock-AF_BLUETOOTH) at: iso_sock_accept+0x61/0x2d0 [bluetooth] [ 41.586064] other info that might help us debug this: [ 41.586069] Possible unsafe locking scenario: [ 41.586072] CPU0 [ 41.586076] ---- [ 41.586079] lock(sk_lock-AF_BLUETOOTH); [ 41.586086] lock(sk_lock-AF_BLUETOOTH); [ 41.586093] *** DEADLOCK *** [ 41.586097] May be due to missing lock nesting notation [ 41.586101] 1 lock held by iso-tester/3139: [ 41.586107] #0: ffff988b29533a58 (sk_lock-AF_BLUETOOTH) at: iso_sock_accept+0x61/0x2d0 [bluetooth] Fixes: ccf74f2 ("Bluetooth: Add BTPROTO_ISO socket type") Signed-off-by: Iulia Tanasescu <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]> Signed-off-by: Bastien Nocera <[email protected]>
1 parent 2486f6e commit a0a2dc1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/bluetooth/iso.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,11 @@ static int iso_sock_accept(struct socket *sock, struct socket *newsock,
12351235
long timeo;
12361236
int err = 0;
12371237

1238-
lock_sock(sk);
1238+
/* Use explicit nested locking to avoid lockdep warnings generated
1239+
* because the parent socket and the child socket are locked on the
1240+
* same thread.
1241+
*/
1242+
lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
12391243

12401244
timeo = sock_rcvtimeo(sk, arg->flags & O_NONBLOCK);
12411245

@@ -1266,7 +1270,7 @@ static int iso_sock_accept(struct socket *sock, struct socket *newsock,
12661270
release_sock(sk);
12671271

12681272
timeo = wait_woken(&wait, TASK_INTERRUPTIBLE, timeo);
1269-
lock_sock(sk);
1273+
lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
12701274
}
12711275
remove_wait_queue(sk_sleep(sk), &wait);
12721276

0 commit comments

Comments
 (0)