linux/net/bluetooth
Tetsuo Handa ddeda6ca5f Bluetooth: hci_core: cancel all works upon hci_unregister_dev()
[ Upstream commit 0d151a1037 ]

syzbot is reporting that calling hci_release_dev() from hci_error_reset()
due to hci_dev_put() from hci_error_reset() can cause deadlock at
destroy_workqueue(), for hci_error_reset() is called from
hdev->req_workqueue which destroy_workqueue() needs to flush.

We need to make sure that hdev->{rx_work,cmd_work,tx_work} which are
queued into hdev->workqueue and hdev->{power_on,error_reset} which are
queued into hdev->req_workqueue are no longer running by the moment

       destroy_workqueue(hdev->workqueue);
       destroy_workqueue(hdev->req_workqueue);

are called from hci_release_dev().

Call cancel_work_sync() on these work items from hci_unregister_dev()
as soon as hdev->list is removed from hci_dev_list.

Reported-by: syzbot <syzbot+da0a9c9721e36db712e8@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=da0a9c9721e36db712e8
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-27 10:40:21 +02:00
..
bnep exit: Rename module_put_and_exit to module_put_and_kthread_exit 2024-06-21 14:53:29 +02:00
cmtp exit: Rename module_put_and_exit to module_put_and_kthread_exit 2024-06-21 14:53:29 +02:00
hidp exit: Rename module_put_and_exit to module_put_and_kthread_exit 2024-06-21 14:53:29 +02:00
rfcomm Bluetooth: rfcomm: Fix null-ptr-deref in rfcomm_check_security 2024-03-26 18:21:47 -04:00
6lowpan.c Bluetooth: 6LoWPAN: add missing hci_dev_put() in get_l2cap_conn() 2022-12-14 11:32:01 +01:00
a2mp.c Bluetooth: drop HCI device reference before return 2021-03-04 11:37:25 +01:00
a2mp.h Bluetooth: Replace zero-length array with flexible-array member 2020-02-28 08:30:02 +01:00
af_bluetooth.c Bluetooth: af_bluetooth: Fix Use-After-Free in bt_sock_recvmsg 2024-01-05 15:12:30 +01:00
amp.c Bluetooth: Fix null pointer dereference in amp_read_loc_assoc_final_data 2021-03-07 12:34:10 +01:00
amp.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284 2019-06-05 17:36:37 +02:00
ecdh_helper.c mm, treewide: rename kzfree() to kfree_sensitive() 2020-08-07 11:33:22 -07:00
ecdh_helper.h Fix misc new gcc warnings 2021-05-11 14:47:36 +02:00
hci_conn.c Bluetooth: Fix bogus check for re-auth no supported with non-ssp 2024-01-25 14:37:46 -08:00
hci_core.c Bluetooth: hci_core: cancel all works upon hci_unregister_dev() 2024-07-27 10:40:21 +02:00
hci_debugfs.c Bluetooth: Fix TOCTOU in HCI debugfs implementation 2024-04-13 12:59:18 +02:00
hci_debugfs.h
hci_event.c Bluetooth: hci_event: set the conn encrypted before conn establishes 2024-04-13 12:59:18 +02:00
hci_request.c Bluetooth: Fix memory leak in hci_req_sync_complete() 2024-05-02 16:23:33 +02:00
hci_request.h Bluetooth: Enable/Disable address resolution during le create conn 2020-07-30 09:34:43 +02:00
hci_sock.c Bluetooth: hci_sock: Correctly bounds check and pad HCI_MON_NEW_INDEX name 2023-10-25 11:54:26 +02:00
hci_sysfs.c Bluetooth: Fix double free in hci_conn_cleanup 2023-11-28 16:54:50 +00:00
Kconfig Bluetooth: Disable High Speed by default 2020-09-25 20:21:55 +02:00
l2cap_core.c Bluetooth: L2CAP: Fix rejecting L2CAP_CONN_PARAM_UPDATE_REQ 2024-07-05 09:12:28 +02:00
l2cap_sock.c Bluetooth: Fix type of len in {l2cap,sco}_sock_getsockopt_old() 2024-05-02 16:23:44 +02:00
leds.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
leds.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
lib.c Bluetooth: Introduce debug feature when dynamic debug is disabled 2020-05-11 12:16:27 +02:00
Makefile Bluetooth: implement read/set default system parameters mgmt 2020-06-12 21:41:07 +02:00
mgmt_config.c Bluetooth: Interleave with allowlist scan 2022-06-09 10:21:08 +02:00
mgmt_config.h Bluetooth: mgmt: Add commands for runtime configuration 2020-06-18 13:11:03 +03:00
mgmt_util.c
mgmt_util.h
mgmt.c Bluetooth: MGMT/SMP: Fix address type when using SMP over BREDR/LE 2024-01-05 15:12:29 +01:00
msft.c Bluetooth: Replace zero-length array with flexible-array member 2020-10-29 17:22:59 -05:00
msft.h Bluetooth: Add handler of MGMT_OP_READ_ADV_MONITOR_FEATURES 2020-06-18 13:11:21 +03:00
sco.c Bluetooth: Fix use-after-free bugs caused by sco_sock_timeout 2024-05-17 11:48:06 +02:00
selftest.c Bluetooth: Remove CRYPTO_ALG_INTERNAL flag 2020-07-31 16:42:04 +03:00
selftest.h
smp.c Bluetooth: SMP: Fix crash when receiving new connection when debug is enabled 2024-01-05 15:12:31 +01:00
smp.h Bluetooth: use inclusive language in SMP 2024-01-05 15:12:29 +01:00