====================================================== WARNING: possible circular locking dependency detected 4.20.0-rc6+ #277 Not tainted ------------------------------------------------------ kworker/0:1/12 is trying to acquire lock: 00000000653d4234 (&mdev->req_queue_mutex){+.+.}, at: v4l2_release+0x1d7/0x3a0 drivers/media/v4l2-core/v4l2-dev.c:455 but task is already holding lock: 00000000a867b049 ((delayed_fput_work).work){+.+.}, at: process_one_work+0xb9a/0x1c40 kernel/workqueue.c:2128 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 ((delayed_fput_work).work){+.+.}: process_one_work+0xc0a/0x1c40 kernel/workqueue.c:2129 worker_thread+0x17f/0x1390 kernel/workqueue.c:2296 kthread+0x35a/0x440 kernel/kthread.c:246 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352 -> #2 ((wq_completion)"events"){+.+.}: flush_workqueue+0x30a/0x1e10 kernel/workqueue.c:2655 flush_scheduled_work include/linux/workqueue.h:599 [inline] vim2m_stop_streaming+0x7c/0x2c0 drivers/media/platform/vim2m.c:811 __vb2_queue_cancel+0x14f/0xd50 drivers/media/common/videobuf2/videobuf2-core.c:1843 vb2_core_queue_release+0x26/0x80 drivers/media/common/videobuf2/videobuf2-core.c:2255 vb2_queue_release+0x15/0x20 drivers/media/common/videobuf2/videobuf2-v4l2.c:842 v4l2_m2m_ctx_release+0x1e/0x35 drivers/media/v4l2-core/v4l2-mem2mem.c:930 vim2m_release+0xe6/0x150 drivers/media/platform/vim2m.c:977 v4l2_release+0x224/0x3a0 drivers/media/v4l2-core/v4l2-dev.c:456 __fput+0x385/0xa30 fs/file_table.c:278 ____fput+0x15/0x20 fs/file_table.c:309 task_work_run+0x1e8/0x2a0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:188 [inline] exit_to_usermode_loop+0x318/0x380 arch/x86/entry/common.c:166 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline] syscall_return_slowpath arch/x86/entry/common.c:268 [inline] do_syscall_32_irqs_on arch/x86/entry/common.c:341 [inline] do_fast_syscall_32+0xcd5/0xfb2 arch/x86/entry/common.c:397 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139 -> #1 (&dev->dev_mutex){+.+.}: __mutex_lock_common kernel/locking/mutex.c:925 [inline] __mutex_lock+0x166/0x16f0 kernel/locking/mutex.c:1072 mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1087 vim2m_release+0xbc/0x150 drivers/media/platform/vim2m.c:976 v4l2_release+0x224/0x3a0 drivers/media/v4l2-core/v4l2-dev.c:456 __fput+0x385/0xa30 fs/file_table.c:278 ____fput+0x15/0x20 fs/file_table.c:309 task_work_run+0x1e8/0x2a0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:188 [inline] exit_to_usermode_loop+0x318/0x380 arch/x86/entry/common.c:166 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline] syscall_return_slowpath arch/x86/entry/common.c:268 [inline] do_syscall_64+0x6be/0x820 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> #0 (&mdev->req_queue_mutex){+.+.}: lock_acquire+0x1ed/0x520 kernel/locking/lockdep.c:3844 __mutex_lock_common kernel/locking/mutex.c:925 [inline] __mutex_lock+0x166/0x16f0 kernel/locking/mutex.c:1072 mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1087 v4l2_release+0x1d7/0x3a0 drivers/media/v4l2-core/v4l2-dev.c:455 __fput+0x385/0xa30 fs/file_table.c:278 delayed_fput+0x55/0x80 fs/file_table.c:304 process_one_work+0xc90/0x1c40 kernel/workqueue.c:2153 worker_thread+0x17f/0x1390 kernel/workqueue.c:2296 kthread+0x35a/0x440 kernel/kthread.c:246 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352 other info that might help us debug this: Chain exists of: &mdev->req_queue_mutex --> (wq_completion)"events" --> (delayed_fput_work).work Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock((delayed_fput_work).work); lock((wq_completion)"events"); lock((delayed_fput_work).work); lock(&mdev->req_queue_mutex); *** DEADLOCK *** 2 locks held by kworker/0:1/12: #0: 00000000bdb7ded2 ((wq_completion)"events"){+.+.}, at: __write_once_size include/linux/compiler.h:209 [inline] #0: 00000000bdb7ded2 ((wq_completion)"events"){+.+.}, at: arch_atomic64_set arch/x86/include/asm/atomic64_64.h:34 [inline] #0: 00000000bdb7ded2 ((wq_completion)"events"){+.+.}, at: atomic64_set include/asm-generic/atomic-instrumented.h:40 [inline] #0: 00000000bdb7ded2 ((wq_completion)"events"){+.+.}, at: atomic_long_set include/asm-generic/atomic-long.h:59 [inline] #0: 00000000bdb7ded2 ((wq_completion)"events"){+.+.}, at: set_work_data kernel/workqueue.c:617 [inline] #0: 00000000bdb7ded2 ((wq_completion)"events"){+.+.}, at: set_work_pool_and_clear_pending kernel/workqueue.c:644 [inline] #0: 00000000bdb7ded2 ((wq_completion)"events"){+.+.}, at: process_one_work+0xb43/0x1c40 kernel/workqueue.c:2124 #1: 00000000a867b049 ((delayed_fput_work).work){+.+.}, at: process_one_work+0xb9a/0x1c40 kernel/workqueue.c:2128 stack backtrace: CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 4.20.0-rc6+ #277 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events delayed_fput Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x244/0x39d lib/dump_stack.c:113 print_circular_bug.isra.35.cold.54+0x1bd/0x27d kernel/locking/lockdep.c:1221 check_prev_add kernel/locking/lockdep.c:1863 [inline] check_prevs_add kernel/locking/lockdep.c:1976 [inline] validate_chain kernel/locking/lockdep.c:2347 [inline] __lock_acquire+0x3399/0x4c20 kernel/locking/lockdep.c:3341 lock_acquire+0x1ed/0x520 kernel/locking/lockdep.c:3844 __mutex_lock_common kernel/locking/mutex.c:925 [inline] __mutex_lock+0x166/0x16f0 kernel/locking/mutex.c:1072 mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1087 v4l2_release+0x1d7/0x3a0 drivers/media/v4l2-core/v4l2-dev.c:455 __fput+0x385/0xa30 fs/file_table.c:278 delayed_fput+0x55/0x80 fs/file_table.c:304 process_one_work+0xc90/0x1c40 kernel/workqueue.c:2153 worker_thread+0x17f/0x1390 kernel/workqueue.c:2296 kthread+0x35a/0x440 kernel/kthread.c:246 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352 kobject: 'loop3' (000000003dbefa55): kobject_uevent_env kobject: 'loop3' (000000003dbefa55): fill_kobj_path: path = '/devices/virtual/block/loop3' kobject: 'loop5' (000000005155d9ea): kobject_uevent_env kobject: 'loop5' (000000005155d9ea): fill_kobj_path: path = '/devices/virtual/block/loop5' kobject: 'loop2' (0000000046dfa2b5): kobject_uevent_env kobject: 'loop2' (0000000046dfa2b5): fill_kobj_path: path = '/devices/virtual/block/loop2' kobject: 'loop4' (000000000c220fae): kobject_uevent_env kobject: 'loop4' (000000000c220fae): fill_kobj_path: path = '/devices/virtual/block/loop4' kobject: 'loop0' (0000000071220de0): kobject_uevent_env kobject: 'loop0' (0000000071220de0): fill_kobj_path: path = '/devices/virtual/block/loop0' kobject: 'loop4' (000000000c220fae): kobject_uevent_env kobject: 'loop4' (000000000c220fae): fill_kobj_path: path = '/devices/virtual/block/loop4' kobject: 'loop3' (000000003dbefa55): kobject_uevent_env kobject: 'loop3' (000000003dbefa55): fill_kobj_path: path = '/devices/virtual/block/loop3' kobject: 'loop0' (0000000071220de0): kobject_uevent_env kobject: 'loop0' (0000000071220de0): fill_kobj_path: path = '/devices/virtual/block/loop0' kobject: 'loop0' (0000000071220de0): kobject_uevent_env kobject: 'loop0' (0000000071220de0): fill_kobj_path: path = '/devices/virtual/block/loop0' kobject: 'loop2' (0000000046dfa2b5): kobject_uevent_env kobject: 'loop2' (0000000046dfa2b5): fill_kobj_path: path = '/devices/virtual/block/loop2' kobject: 'rfkill65' (000000009fed8e6d): kobject_uevent_env kobject: 'rfkill65' (000000009fed8e6d): fill_kobj_path: path = '/devices/virtual/bluetooth/hci1/rfkill65' kobject: 'rfkill65' (000000009fed8e6d): kobject_cleanup, parent (null) kobject: 'rfkill65' (000000009fed8e6d): calling ktype release kobject: 'rfkill65': free name kobject: 'hci1' (00000000fea440c5): kobject_uevent_env kobject: 'hci1' (00000000fea440c5): fill_kobj_path: path = '/devices/virtual/bluetooth/hci1' kobject: 'bluetooth' (000000003c525784): kobject_cleanup, parent (null) kobject: 'bluetooth' (000000003c525784): calling ktype release kobject: 'bluetooth': free name kobject: 'hci1' (00000000fea440c5): kobject_cleanup, parent (null) kobject: 'hci1' (00000000fea440c5): calling ktype release kobject: 'hci1': free name kobject: 'loop1' (00000000ce1b7483): kobject_uevent_env kobject: 'loop1' (00000000ce1b7483): fill_kobj_path: path = '/devices/virtual/block/loop1' kobject: 'loop2' (0000000046dfa2b5): kobject_uevent_env kobject: 'loop2' (0000000046dfa2b5): fill_kobj_path: path = '/devices/virtual/block/loop2' kobject: 'nullb0' (0000000058100f99): kobject_uevent_env kobject: 'nullb0' (0000000058100f99): fill_kobj_path: path = '/devices/virtual/block/nullb0' kobject: 'nullb0' (0000000058100f99): kobject_uevent_env kobject: 'nullb0' (0000000058100f99): fill_kobj_path: path = '/devices/virtual/block/nullb0' kobject: 'loop4' (000000000c220fae): kobject_uevent_env kobject: 'loop4' (000000000c220fae): fill_kobj_path: path = '/devices/virtual/block/loop4' kobject: 'loop2' (0000000046dfa2b5): kobject_uevent_env kobject: 'loop2' (0000000046dfa2b5): fill_kobj_path: path = '/devices/virtual/block/loop2' kobject: 'loop3' (000000003dbefa55): kobject_uevent_env kobject: 'loop3' (000000003dbefa55): fill_kobj_path: path = '/devices/virtual/block/loop3' kobject: 'loop5' (000000005155d9ea): kobject_uevent_env kobject: 'loop5' (000000005155d9ea): fill_kobj_path: path = '/devices/virtual/block/loop5' kobject: 'loop2' (0000000046dfa2b5): kobject_uevent_env kobject: 'loop2' (0000000046dfa2b5): fill_kobj_path: path = '/devices/virtual/block/loop2' kobject: 'loop5' (000000005155d9ea): kobject_uevent_env kobject: 'loop5' (000000005155d9ea): fill_kobj_path: path = '/devices/virtual/block/loop5' kobject: 'loop3' (000000003dbefa55): kobject_uevent_env kobject: 'loop3' (000000003dbefa55): fill_kobj_path: path = '/devices/virtual/block/loop3' kobject: 'loop4' (000000000c220fae): kobject_uevent_env kobject: 'loop4' (000000000c220fae): fill_kobj_path: path = '/devices/virtual/block/loop4' kobject: 'loop1' (00000000ce1b7483): kobject_uevent_env kobject: 'loop1' (00000000ce1b7483): fill_kobj_path: path = '/devices/virtual/block/loop1' kobject: 'loop2' (0000000046dfa2b5): kobject_uevent_env kobject: 'loop2' (0000000046dfa2b5): fill_kobj_path: path = '/devices/virtual/block/loop2' kobject: 'nullb0' (0000000058100f99): kobject_uevent_env kobject: 'nullb0' (0000000058100f99): fill_kobj_path: path = '/devices/virtual/block/nullb0' kobject: 'nullb0' (0000000058100f99): kobject_uevent_env kobject: 'nullb0' (0000000058100f99): fill_kobj_path: path = '/devices/virtual/block/nullb0' kobject: 'loop1' (00000000ce1b7483): kobject_uevent_env kobject: 'loop1' (00000000ce1b7483): fill_kobj_path: path = '/devices/virtual/block/loop1' kobject: 'loop0' (0000000071220de0): kobject_uevent_env kobject: 'loop0' (0000000071220de0): fill_kobj_path: path = '/devices/virtual/block/loop0' kobject: 'bluetooth' (00000000a08fd7d3): kobject_add_internal: parent: 'virtual', set: '(null)' kobject: 'hci1' (00000000e5949951): kobject_add_internal: parent: 'bluetooth', set: 'devices' kobject: 'nullb0' (0000000058100f99): kobject_uevent_env kobject: 'nullb0' (0000000058100f99): fill_kobj_path: path = '/devices/virtual/block/nullb0' kobject: 'loop4' (000000000c220fae): kobject_uevent_env kobject: 'loop4' (000000000c220fae): fill_kobj_path: path = '/devices/virtual/block/loop4' kobject: 'hci1' (00000000e5949951): kobject_uevent_env kobject: 'loop5' (000000005155d9ea): kobject_uevent_env kobject: 'loop5' (000000005155d9ea): fill_kobj_path: path = '/devices/virtual/block/loop5' kobject: 'loop2' (0000000046dfa2b5): kobject_uevent_env kobject: 'loop2' (0000000046dfa2b5): fill_kobj_path: path = '/devices/virtual/block/loop2' kobject: 'hci1' (00000000e5949951): fill_kobj_path: path = '/devices/virtual/bluetooth/hci1' kobject: 'loop1' (00000000ce1b7483): kobject_uevent_env kobject: 'loop1' (00000000ce1b7483): fill_kobj_path: path = '/devices/virtual/block/loop1' kobject: 'nullb0' (0000000058100f99): kobject_uevent_env kobject: 'nullb0' (0000000058100f99): fill_kobj_path: path = '/devices/virtual/block/nullb0' kobject: 'rfkill66' (00000000c4b27e5f): kobject_add_internal: parent: 'hci1', set: 'devices' kobject: 'loop3' (000000003dbefa55): kobject_uevent_env kobject: 'loop3' (000000003dbefa55): fill_kobj_path: path = '/devices/virtual/block/loop3' kobject: 'rfkill66' (00000000c4b27e5f): kobject_uevent_env kobject: 'loop4' (000000000c220fae): kobject_uevent_env kobject: 'loop4' (000000000c220fae): fill_kobj_path: path = '/devices/virtual/block/loop4' kobject: 'rfkill66' (00000000c4b27e5f): fill_kobj_path: path = '/devices/virtual/bluetooth/hci1/rfkill66' kobject: 'rfkill66' (00000000c4b27e5f): kobject_uevent_env kobject: 'rfkill66' (00000000c4b27e5f): fill_kobj_path: path = '/devices/virtual/bluetooth/hci1/rfkill66' kobject: 'nullb0' (0000000058100f99): kobject_uevent_env kobject: 'nullb0' (0000000058100f99): fill_kobj_path: path = '/devices/virtual/block/nullb0' kobject: 'loop2' (0000000046dfa2b5): kobject_uevent_env kobject: 'loop2' (0000000046dfa2b5): fill_kobj_path: path = '/devices/virtual/block/loop2' kobject: 'nullb0' (0000000058100f99): kobject_uevent_env kobject: 'nullb0' (0000000058100f99): fill_kobj_path: path = '/devices/virtual/block/nullb0' kobject: 'loop4' (000000000c220fae): kobject_uevent_env kobject: 'loop4' (000000000c220fae): fill_kobj_path: path = '/devices/virtual/block/loop4' kobject: 'loop3' (000000003dbefa55): kobject_uevent_env kobject: 'loop3' (000000003dbefa55): fill_kobj_path: path = '/devices/virtual/block/loop3' kobject: 'nullb0' (0000000058100f99): kobject_uevent_env kobject: 'nullb0' (0000000058100f99): fill_kobj_path: path = '/devices/virtual/block/nullb0' kobject: 'loop5' (000000005155d9ea): kobject_uevent_env kobject: 'loop5' (000000005155d9ea): fill_kobj_path: path = '/devices/virtual/block/loop5' kobject: 'loop4' (000000000c220fae): kobject_uevent_env kobject: 'loop4' (000000000c220fae): fill_kobj_path: path = '/devices/virtual/block/loop4' kobject: 'nullb0' (0000000058100f99): kobject_uevent_env kobject: 'nullb0' (0000000058100f99): fill_kobj_path: path = '/devices/virtual/block/nullb0' kobject: 'loop3' (000000003dbefa55): kobject_uevent_env kobject: 'loop3' (000000003dbefa55): fill_kobj_path: path = '/devices/virtual/block/loop3' kobject: 'loop4' (000000000c220fae): kobject_uevent_env kobject: 'kvm' (00000000985d85a0): kobject_uevent_env kobject: 'loop4' (000000000c220fae): fill_kobj_path: path = '/devices/virtual/block/loop4' kobject: 'kvm' (00000000985d85a0): fill_kobj_path: path = '/devices/virtual/misc/kvm' kobject: 'loop1' (00000000ce1b7483): kobject_uevent_env kobject: 'loop1' (00000000ce1b7483): fill_kobj_path: path = '/devices/virtual/block/loop1' kobject: 'rx-0' (00000000ed2c898e): kobject_cleanup, parent 00000000815e39b7 kobject: 'rx-0' (00000000ed2c898e): auto cleanup 'remove' event kobject: 'rx-0' (00000000ed2c898e): kobject_uevent_env kobject: 'rx-0' (00000000ed2c898e): fill_kobj_path: path = '/devices/virtual/net/syz_tun/queues/rx-0' kobject: 'rx-0' (00000000ed2c898e): auto cleanup kobject_del kobject: 'rx-0' (00000000ed2c898e): calling ktype release kobject: 'rx-0': free name kobject: 'tx-0' (0000000019afe2ab): kobject_cleanup, parent 00000000815e39b7 kobject: 'tx-0' (0000000019afe2ab): auto cleanup 'remove' event kobject: 'tx-0' (0000000019afe2ab): kobject_uevent_env kobject: 'tx-0' (0000000019afe2ab): fill_kobj_path: path = '/devices/virtual/net/syz_tun/queues/tx-0' kobject: 'tx-0' (0000000019afe2ab): auto cleanup kobject_del kobject: 'tx-0' (0000000019afe2ab): calling ktype release kobject: 'tx-0': free name kobject: 'queues' (00000000815e39b7): kobject_cleanup, parent (null) kobject: 'queues' (00000000815e39b7): calling ktype release kobject: 'queues' (00000000815e39b7): kset_release kobject: 'queues': free name kobject: 'syz_tun' (000000008b2c57f2): kobject_uevent_env kobject: 'syz_tun' (000000008b2c57f2): fill_kobj_path: path = '/devices/virtual/net/syz_tun' kobject: 'syz_tun' (000000008b2c57f2): kobject_cleanup, parent (null) kobject: 'syz_tun' (000000008b2c57f2): calling ktype release kobject: 'syz_tun': free name