====================================================== WARNING: possible circular locking dependency detected syzkaller #0 Tainted: G L ------------------------------------------------------ krfcommd/3373 is trying to acquire lock: ffff8880565f7940 ((wq_completion)hci1){+.+.}-{0:0}, at: touch_wq_lockdep_map+0x9c/0x1c0 kernel/workqueue.c:4111 but task is already holding lock: ffffffff91f84b40 (rfcomm_mutex){+.+.}-{4:4}, at: rfcomm_process_sessions net/bluetooth/rfcomm/core.c:2152 [inline] ffffffff91f84b40 (rfcomm_mutex){+.+.}-{4:4}, at: rfcomm_run+0x30b/0x5550 net/bluetooth/rfcomm/core.c:2261 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+0x1a4/0x1bd0 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/0xe20 drivers/tty/tty_io.c:2112 chrdev_open+0x234/0x6a0 fs/char_dev.c:411 do_dentry_open+0x6ab/0x14d0 fs/open.c:996 vfs_open+0x82/0x3f0 fs/open.c:1101 do_open fs/namei.c:4866 [inline] path_openat+0x19fa/0x2440 fs/namei.c:5029 do_file_open+0x20e/0x430 fs/namei.c:5058 do_sys_openat2+0x10f/0x1e0 fs/open.c:1417 do_sys_open fs/open.c:1423 [inline] __do_sys_open fs/open.c:1431 [inline] __se_sys_open fs/open.c:1427 [inline] __x64_sys_open+0xfe/0x1d0 fs/open.c:1427 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+0x1a4/0x1bd0 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+0x5c8/0x880 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+0x12f0/0x1800 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+0x8b/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 tty_release+0x40e/0x1300 drivers/tty/tty_io.c:1720 __fput+0x400/0xb60 fs/file_table.c:512 task_work_run+0x150/0x240 kernel/task_work.c:233 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline] __exit_to_user_mode_loop kernel/entry/common.c:70 [inline] exit_to_user_mode_loop+0x1d8/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+0x1a4/0x1bd0 kernel/locking/mutex.c:821 tty_buffer_flush+0x72/0x310 drivers/tty/tty_buffer.c:236 pty_flush_buffer+0x4d/0x130 drivers/tty/pty.c:211 tty_driver_flush_buffer+0x64/0x80 drivers/tty/tty_ioctl.c:85 hci_uart_flush+0xfc/0x630 drivers/bluetooth/hci_ldisc.c:256 hci_uart_close+0x1d/0x90 drivers/bluetooth/hci_ldisc.c:292 hci_dev_open_sync+0x126f/0x25e0 net/bluetooth/hci_sync.c:5494 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:3396 process_scheduled_works kernel/workqueue.c:3479 [inline] worker_thread+0x5ef/0xe50 kernel/workqueue.c:3560 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+0x1a4/0x1bd0 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:3396 process_scheduled_works kernel/workqueue.c:3479 [inline] worker_thread+0x5ef/0xe50 kernel/workqueue.c:3560 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:3372 process_scheduled_works kernel/workqueue.c:3479 [inline] worker_thread+0x5ef/0xe50 kernel/workqueue.c:3560 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)hci1){+.+.}-{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:4111 __flush_workqueue+0x131/0x1200 kernel/workqueue.c:4153 drain_workqueue+0x175/0x3b0 kernel/workqueue.c:4317 destroy_workqueue+0xc3/0xa30 kernel/workqueue.c:6155 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:1690 [inline] l2cap_conn_free net/bluetooth/l2cap_core.c:1856 [inline] kref_put include/linux/kref.h:65 [inline] l2cap_conn_put net/bluetooth/l2cap_core.c:1869 [inline] l2cap_chan_destroy net/bluetooth/l2cap_core.c:494 [inline] kref_put include/linux/kref.h:65 [inline] l2cap_chan_put+0x352/0x3f0 net/bluetooth/l2cap_core.c:521 l2cap_sock_release+0x1db/0x280 net/bluetooth/l2cap_sock.c:1533 __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:2086 [inline] rfcomm_process_sessions net/bluetooth/rfcomm/core.c:2171 [inline] rfcomm_run+0x6f6/0x5550 net/bluetooth/rfcomm/core.c:2261 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)hci1 --> &port->mutex --> rfcomm_mutex Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(rfcomm_mutex); lock(&port->mutex); lock(rfcomm_mutex); lock((wq_completion)hci1); *** DEADLOCK *** locks held by krfcommd/3373: 1, last CPU#3: #0: ffffffff91f84b40 (rfcomm_mutex){+.+.}-{4:4}, at: rfcomm_process_sessions net/bluetooth/rfcomm/core.c:2152 [inline] #0: ffffffff91f84b40 (rfcomm_mutex){+.+.}-{4:4}, at: rfcomm_run+0x30b/0x5550 net/bluetooth/rfcomm/core.c:2261 stack backtrace: CPU: 3 UID: 0 PID: 3373 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:4111 __flush_workqueue+0x131/0x1200 kernel/workqueue.c:4153 drain_workqueue+0x175/0x3b0 kernel/workqueue.c:4317 destroy_workqueue+0xc3/0xa30 kernel/workqueue.c:6155 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:1690 [inline] l2cap_conn_free net/bluetooth/l2cap_core.c:1856 [inline] kref_put include/linux/kref.h:65 [inline] l2cap_conn_put net/bluetooth/l2cap_core.c:1869 [inline] l2cap_chan_destroy net/bluetooth/l2cap_core.c:494 [inline] kref_put include/linux/kref.h:65 [inline] l2cap_chan_put+0x352/0x3f0 net/bluetooth/l2cap_core.c:521 l2cap_sock_release+0x1db/0x280 net/bluetooth/l2cap_sock.c:1533 __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:2086 [inline] rfcomm_process_sessions net/bluetooth/rfcomm/core.c:2171 [inline] rfcomm_run+0x6f6/0x5550 net/bluetooth/rfcomm/core.c:2261 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