====================================================== WARNING: possible circular locking dependency detected syzkaller #0 Tainted: G L ------------------------------------------------------ krfcommd/3411 is trying to acquire lock: ffff8880379b4948 ((wq_completion)hci2){+.+.}-{0:0}, at: touch_wq_lockdep_map+0x9c/0x1c0 kernel/workqueue.c:4272 but task is already holding lock: ffffffff921b5c00 (rfcomm_mutex){+.+.}-{4:4}, at: rfcomm_process_sessions net/bluetooth/rfcomm/core.c:2150 [inline] ffffffff921b5c00 (rfcomm_mutex){+.+.}-{4:4}, at: rfcomm_run+0x30b/0x5560 net/bluetooth/rfcomm/core.c:2259 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #6 (rfcomm_mutex){+.+.}-{4:4}: lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x19f/0x1c10 kernel/locking/mutex.c:821 rfcomm_dlc_open+0xb5/0x760 net/bluetooth/rfcomm/core.c:422 rfcomm_dev_activate+0x83/0x110 net/bluetooth/rfcomm/tty.c:112 tty_port_open+0x161/0x220 drivers/tty/tty_port.c:798 rfcomm_tty_open+0xad/0x490 net/bluetooth/rfcomm/tty.c:744 tty_open+0x2cc/0xee0 drivers/tty/tty_io.c:2112 chrdev_open+0x234/0x6a0 fs/char_dev.c:413 do_dentry_open+0x674/0x1470 fs/open.c:1000 vfs_open_consume+0xcc/0x460 fs/open.c:1131 do_open fs/namei.c:4845 [inline] path_openat+0x1547/0x23f0 fs/namei.c:5010 do_file_open+0x20e/0x430 fs/namei.c:5039 do_sys_openat2+0x163/0x1d0 fs/open.c:1442 do_sys_open fs/open.c:1448 [inline] __do_sys_openat fs/open.c:1464 [inline] __se_sys_openat fs/open.c:1459 [inline] __x64_sys_openat+0x12d/0x210 fs/open.c:1459 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #5 (&port->mutex){+.+.}-{4:4}: lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x19f/0x1c10 kernel/locking/mutex.c:821 class_mutex_constructor include/linux/mutex.h:253 [inline] uart_set_termios+0x8a/0x6f0 drivers/tty/serial/serial_core.c:1662 tty_set_termios+0x64d/0x980 drivers/tty/tty_ioctl.c:341 set_termios+0x5c3/0x8e0 drivers/tty/tty_ioctl.c:516 tty_mode_ioctl+0x17e/0xd40 drivers/tty/tty_ioctl.c:803 n_tty_ioctl_helper+0x47/0x2b0 drivers/tty/tty_ioctl.c:982 n_tty_ioctl+0x53/0x340 drivers/tty/n_tty.c:2496 tty_ioctl+0x12f4/0x1870 drivers/tty/tty_io.c:2791 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:597 [inline] __se_sys_ioctl fs/ioctl.c:583 [inline] __x64_sys_ioctl+0x18e/0x210 fs/ioctl.c:583 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #4 (&tty->termios_rwsem){++++}-{4:4}: lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 down_write+0x86/0x1f0 kernel/locking/rwsem.c:1631 class_rwsem_write_constructor include/linux/rwsem.h:270 [inline] n_tty_flush_buffer+0x25/0x1b0 drivers/tty/n_tty.c:349 tty_buffer_flush+0x239/0x310 drivers/tty/tty_buffer.c:248 tty_ldisc_flush+0x68/0xf0 drivers/tty/tty_ldisc.c:388 tty_port_close_start+0x306/0x500 drivers/tty/tty_port.c:677 tty_port_close+0x26/0x180 drivers/tty/tty_port.c:732 uart_close+0x7d/0x240 drivers/tty/serial/serial_core.c:1731 tty_release+0x40e/0x1300 drivers/tty/tty_io.c:1720 __fput+0x3fb/0xb50 fs/file_table.c:512 task_work_run+0x150/0x240 kernel/task_work.c:233 get_signal+0x1bd/0x21d0 kernel/signal.c:2884 arch_do_signal_or_restart+0x91/0x7e0 arch/x86/kernel/signal.c:337 __exit_to_user_mode_loop kernel/entry/common.c:66 [inline] exit_to_user_mode_loop+0x139/0x700 kernel/entry/common.c:101 __exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline] syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:230 [inline] syscall_exit_to_user_mode include/linux/entry-common.h:343 [inline] do_syscall_64+0x661/0x790 arch/x86/entry/syscall_64.c:89 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #3 (&buf->lock){+.+.}-{4:4}: lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x19f/0x1c10 kernel/locking/mutex.c:821 tty_buffer_flush+0x72/0x310 drivers/tty/tty_buffer.c:236 tty_ldisc_flush+0xad/0xf0 drivers/tty/tty_ldisc.c:388 hci_uart_flush+0xed/0x630 drivers/bluetooth/hci_ldisc.c:255 hci_uart_close+0x1d/0x90 drivers/bluetooth/hci_ldisc.c:292 hci_dev_drop_last_cmd_req_and_close+0x17e/0x200 net/bluetooth/hci_sync.c:5459 hci_dev_open_sync+0x1120/0x2410 net/bluetooth/hci_sync.c:5551 hci_dev_do_open+0x2a/0xb0 net/bluetooth/hci_core.c:431 hci_power_on+0x131/0x630 net/bluetooth/hci_core.c:923 process_one_work+0xac7/0x1b10 kernel/workqueue.c:3495 process_scheduled_works kernel/workqueue.c:3578 [inline] worker_thread+0x5ef/0xe50 kernel/workqueue.c:3659 kthread+0x373/0x450 kernel/kthread.c:436 ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 -> #2 (&hdev->req_lock){+.+.}-{4:4}: lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x19f/0x1c10 kernel/locking/mutex.c:821 hci_dev_do_open+0x22/0xb0 net/bluetooth/hci_core.c:429 hci_power_on+0x131/0x630 net/bluetooth/hci_core.c:923 process_one_work+0xac7/0x1b10 kernel/workqueue.c:3495 process_scheduled_works kernel/workqueue.c:3578 [inline] worker_thread+0x5ef/0xe50 kernel/workqueue.c:3659 kthread+0x373/0x450 kernel/kthread.c:436 ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 -> #1 ((work_completion)(&hdev->power_on)){+.+.}-{0:0}: lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 process_one_work+0xa32/0x1b10 kernel/workqueue.c:3471 process_scheduled_works kernel/workqueue.c:3578 [inline] worker_thread+0x5ef/0xe50 kernel/workqueue.c:3659 kthread+0x373/0x450 kernel/kthread.c:436 ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 -> #0 ((wq_completion)hci2){+.+.}-{0:0}: check_prev_add+0xeb/0xe60 kernel/locking/lockdep.c:3209 check_prevs_add kernel/locking/lockdep.c:3328 [inline] validate_chain kernel/locking/lockdep.c:3952 [inline] __lock_acquire+0x1528/0x1f40 kernel/locking/lockdep.c:5288 lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 touch_wq_lockdep_map+0xad/0x1c0 kernel/workqueue.c:4272 __flush_workqueue+0x131/0x1200 kernel/workqueue.c:4314 drain_workqueue+0x175/0x3c0 kernel/workqueue.c:4478 destroy_workqueue+0xc1/0x9f0 kernel/workqueue.c:6372 hci_release_dev+0x14d/0x630 net/bluetooth/hci_core.c:2729 bt_host_release+0x6b/0xb0 net/bluetooth/hci_sysfs.c:100 device_release+0xd2/0x270 drivers/base/core.c:2640 kobject_cleanup lib/kobject.c:689 [inline] kobject_release lib/kobject.c:720 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x1f7/0x640 lib/kobject.c:737 put_device+0x1f/0x30 drivers/base/core.c:3884 device_release+0xd2/0x270 drivers/base/core.c:2640 kobject_cleanup lib/kobject.c:689 [inline] kobject_release lib/kobject.c:720 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x1f7/0x640 lib/kobject.c:737 put_device+0x1f/0x30 drivers/base/core.c:3884 hci_conn_put include/net/bluetooth/hci_core.h:1737 [inline] l2cap_conn_free net/bluetooth/l2cap_core.c:1960 [inline] kref_put include/linux/kref.h:65 [inline] l2cap_conn_put net/bluetooth/l2cap_core.c:1973 [inline] l2cap_chan_destroy net/bluetooth/l2cap_core.c:522 [inline] kref_put include/linux/kref.h:65 [inline] l2cap_chan_put+0x352/0x3f0 net/bluetooth/l2cap_core.c:549 l2cap_sock_release+0x1db/0x280 net/bluetooth/l2cap_sock.c:1540 __sock_release net/socket.c:735 [inline] sock_release+0x91/0x1c0 net/socket.c:763 rfcomm_session_del.isra.0+0x16b/0x250 net/bluetooth/rfcomm/core.c:782 rfcomm_process_rx net/bluetooth/rfcomm/core.c:2084 [inline] rfcomm_process_sessions net/bluetooth/rfcomm/core.c:2169 [inline] rfcomm_run+0x6f6/0x5560 net/bluetooth/rfcomm/core.c:2259 kthread+0x373/0x450 kernel/kthread.c:436 ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 other info that might help us debug this: Chain exists of: (wq_completion)hci2 --> &port->mutex --> rfcomm_mutex Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(rfcomm_mutex); lock(&port->mutex); lock(rfcomm_mutex); lock((wq_completion)hci2); *** DEADLOCK *** locks held by krfcommd/3411: 1, last CPU#1: #0: ffffffff921b5c00 (rfcomm_mutex){+.+.}-{4:4}, at: rfcomm_process_sessions net/bluetooth/rfcomm/core.c:2150 [inline] #0: ffffffff921b5c00 (rfcomm_mutex){+.+.}-{4:4}, at: rfcomm_run+0x30b/0x5560 net/bluetooth/rfcomm/core.c:2259 stack backtrace: CPU: 1 UID: 0 PID: 3411 Comm: krfcommd Tainted: G L syzkaller #0 PREEMPT(full) Tainted: [L]=SOFTLOCKUP Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120 print_circular_bug.cold+0x178/0x1be kernel/locking/lockdep.c:2087 check_noncircular+0x146/0x160 kernel/locking/lockdep.c:2219 check_prev_add+0xeb/0xe60 kernel/locking/lockdep.c:3209 check_prevs_add kernel/locking/lockdep.c:3328 [inline] validate_chain kernel/locking/lockdep.c:3952 [inline] __lock_acquire+0x1528/0x1f40 kernel/locking/lockdep.c:5288 lock_acquire kernel/locking/lockdep.c:5942 [inline] lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899 touch_wq_lockdep_map+0xad/0x1c0 kernel/workqueue.c:4272 __flush_workqueue+0x131/0x1200 kernel/workqueue.c:4314 drain_workqueue+0x175/0x3c0 kernel/workqueue.c:4478 destroy_workqueue+0xc1/0x9f0 kernel/workqueue.c:6372 hci_release_dev+0x14d/0x630 net/bluetooth/hci_core.c:2729 bt_host_release+0x6b/0xb0 net/bluetooth/hci_sysfs.c:100 device_release+0xd2/0x270 drivers/base/core.c:2640 kobject_cleanup lib/kobject.c:689 [inline] kobject_release lib/kobject.c:720 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x1f7/0x640 lib/kobject.c:737 put_device+0x1f/0x30 drivers/base/core.c:3884 device_release+0xd2/0x270 drivers/base/core.c:2640 kobject_cleanup lib/kobject.c:689 [inline] kobject_release lib/kobject.c:720 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x1f7/0x640 lib/kobject.c:737 put_device+0x1f/0x30 drivers/base/core.c:3884 hci_conn_put include/net/bluetooth/hci_core.h:1737 [inline] l2cap_conn_free net/bluetooth/l2cap_core.c:1960 [inline] kref_put include/linux/kref.h:65 [inline] l2cap_conn_put net/bluetooth/l2cap_core.c:1973 [inline] l2cap_chan_destroy net/bluetooth/l2cap_core.c:522 [inline] kref_put include/linux/kref.h:65 [inline] l2cap_chan_put+0x352/0x3f0 net/bluetooth/l2cap_core.c:549 l2cap_sock_release+0x1db/0x280 net/bluetooth/l2cap_sock.c:1540 __sock_release net/socket.c:735 [inline] sock_release+0x91/0x1c0 net/socket.c:763 rfcomm_session_del.isra.0+0x16b/0x250 net/bluetooth/rfcomm/core.c:782 rfcomm_process_rx net/bluetooth/rfcomm/core.c:2084 [inline] rfcomm_process_sessions net/bluetooth/rfcomm/core.c:2169 [inline] rfcomm_run+0x6f6/0x5560 net/bluetooth/rfcomm/core.c:2259 kthread+0x373/0x450 kernel/kthread.c:436 ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245