sst-linux/net/bluetooth
Luiz Augusto von Dentz 0013017242 Bluetooth: L2CAP: Fix deadlock
commit f1a8f402f13f94263cf349216c257b2985100927 upstream.

This fixes the following deadlock introduced by 39a92a55be13
("bluetooth/l2cap: sync sock recv cb and release")

============================================
WARNING: possible recursive locking detected
6.10.0-rc3-g4029dba6b6f1 #6823 Not tainted
--------------------------------------------
kworker/u5:0/35 is trying to acquire lock:
ffff888002ec2510 (&chan->lock#2/1){+.+.}-{3:3}, at:
l2cap_sock_recv_cb+0x44/0x1e0

but task is already holding lock:
ffff888002ec2510 (&chan->lock#2/1){+.+.}-{3:3}, at:
l2cap_get_chan_by_scid+0xaf/0xd0

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&chan->lock#2/1);
  lock(&chan->lock#2/1);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

3 locks held by kworker/u5:0/35:
 #0: ffff888002b8a940 ((wq_completion)hci0#2){+.+.}-{0:0}, at:
process_one_work+0x750/0x930
 #1: ffff888002c67dd0 ((work_completion)(&hdev->rx_work)){+.+.}-{0:0},
at: process_one_work+0x44e/0x930
 #2: ffff888002ec2510 (&chan->lock#2/1){+.+.}-{3:3}, at:
l2cap_get_chan_by_scid+0xaf/0xd0

To fix the original problem this introduces l2cap_chan_lock at
l2cap_conless_channel to ensure that l2cap_sock_recv_cb is called with
chan->lock held.

Fixes: 89e856e124f9 ("bluetooth/l2cap: sync sock recv cb and release")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-07-25 09:49:20 +02:00
..
bnep Bluetooth: Consolidate code around sk_alloc into a helper function 2024-06-12 11:03:20 +02:00
cmtp
hidp
rfcomm Bluetooth: Consolidate code around sk_alloc into a helper function 2024-06-12 11:03:20 +02:00
6lowpan.c
a2mp.c
a2mp.h
af_bluetooth.c Bluetooth: Consolidate code around sk_alloc into a helper function 2024-06-12 11:03:20 +02:00
amp.c
amp.h
aosp.c
aosp.h
ecdh_helper.c
ecdh_helper.h
eir.c Bluetooth: Fix eir name length 2024-03-26 18:20:42 -04:00
eir.h
hci_codec.c
hci_codec.h
hci_conn.c Bluetooth: hci_sync: Fix overwriting request callback 2024-03-26 18:20:40 -04:00
hci_core.c Bluetooth: L2CAP: Fix deadlock 2024-07-25 09:49:20 +02:00
hci_debugfs.c Bluetooth: Fix TOCTOU in HCI debugfs implementation 2024-04-10 16:28:24 +02:00
hci_debugfs.h
hci_event.c Bluetooth: hci_event: set the conn encrypted before conn establishes 2024-04-10 16:28:24 +02:00
hci_request.c Bluetooth: Fix memory leak in hci_req_sync_complete() 2024-04-17 11:18:22 +02:00
hci_request.h Bluetooth: Delete unused hci_req_prepare_suspend() declaration 2023-10-10 22:00:40 +02:00
hci_sock.c Bluetooth: Consolidate code around sk_alloc into a helper function 2024-06-12 11:03:20 +02:00
hci_sync.c Bluetooth: L2CAP: Fix deadlock 2024-07-25 09:49:20 +02:00
hci_sysfs.c Bluetooth: Fix double free in hci_conn_cleanup 2023-11-28 17:06:56 +00:00
iso.c Bluetooth: Consolidate code around sk_alloc into a helper function 2024-06-12 11:03:20 +02:00
Kconfig
l2cap_core.c Bluetooth: L2CAP: Fix deadlock 2024-07-25 09:49:20 +02:00
l2cap_sock.c Bluetooth: L2CAP: Fix deadlock 2024-07-25 09:49:20 +02:00
leds.c
leds.h
lib.c
Makefile
mgmt_config.c
mgmt_config.h
mgmt_util.c
mgmt_util.h
mgmt.c Bluetooth: hci_sync: Using hci_cmd_sync_submit when removing Adv Monitor 2024-05-02 16:29:25 +02:00
msft.c Bluetooth: msft: fix slab-use-after-free in msft_do_close() 2024-05-17 11:56:11 +02:00
msft.h Bluetooth: msft: fix slab-use-after-free in msft_do_close() 2024-05-17 11:56:11 +02:00
sco.c Bluetooth: Consolidate code around sk_alloc into a helper function 2024-06-12 11:03:20 +02:00
selftest.c
selftest.h
smp.c Bluetooth: MGMT/SMP: Fix address type when using SMP over BREDR/LE 2024-01-01 12:39:03 +00:00
smp.h