===================================================== WARNING: SOFTIRQ-safe -> SOFTIRQ-unsafe lock order detected 5.2.0-rc6 #6 Not tainted ----------------------------------------------------- syz-executor.2/5567 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire: 00000000cbf72d20 (&ctx->fault_pending_wqh){+.+.}, at: spin_lock include/linux/spinlock.h:338 [inline] 00000000cbf72d20 (&ctx->fault_pending_wqh){+.+.}, at: userfaultfd_ctx_read+0x3e7/0x1430 fs/userfaultfd.c:1045 and this task is already holding: 0000000094949b68 (&ctx->fd_wqh){....}, at: spin_lock_irq include/linux/spinlock.h:363 [inline] 0000000094949b68 (&ctx->fd_wqh){....}, at: userfaultfd_ctx_read+0x198/0x1430 fs/userfaultfd.c:1041 which would create a new lock dependency: (&ctx->fd_wqh){....} -> (&ctx->fault_pending_wqh){+.+.} but this new dependency connects a SOFTIRQ-irq-safe lock: (&(&ctx->ctx_lock)->rlock){..-.} ... which became SOFTIRQ-irq-safe at: __raw_spin_lock_irq include/linux/spinlock_api_smp.h:128 [inline] _raw_spin_lock_irq+0x6a/0x80 kernel/locking/spinlock.c:167 spin_lock_irq include/linux/spinlock.h:363 [inline] free_ioctx_users+0x33/0x1d0 fs/aio.c:620 percpu_ref_put_many include/linux/percpu-refcount.h:285 [inline] percpu_ref_put+0x1c6/0x1d0 include/linux/percpu-refcount.h:301 percpu_ref_call_confirm_rcu lib/percpu-refcount.c:124 [inline] percpu_ref_switch_to_atomic_rcu+0x260/0x310 lib/percpu-refcount.c:159 __rcu_reclaim kernel/rcu/rcu.h:222 [inline] rcu_do_batch kernel/rcu/tree.c:2092 [inline] invoke_rcu_callbacks kernel/rcu/tree.c:2310 [inline] rcu_core+0x8d6/0xf90 kernel/rcu/tree.c:2291 __do_softirq+0x340/0x7b0 arch/x86/include/asm/paravirt.h:777 run_ksoftirqd+0x64/0xf0 kernel/softirq.c:603 smpboot_thread_fn+0x62c/0xa50 kernel/smpboot.c:165 kthread+0x325/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 to a SOFTIRQ-irq-unsafe lock: (&ctx->fault_pending_wqh){+.+.} ... which became SOFTIRQ-irq-unsafe at: ... __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2d/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:338 [inline] userfaultfd_release+0x4dc/0x620 fs/userfaultfd.c:921 __fput+0x2e4/0x740 fs/file_table.c:280 ____fput+0x15/0x20 fs/file_table.c:313 task_work_run+0x17e/0x1b0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:185 [inline] exit_to_usermode_loop arch/x86/entry/common.c:168 [inline] prepare_exit_to_usermode+0x402/0x4f0 arch/x86/entry/common.c:199 syscall_return_slowpath+0x110/0x440 arch/x86/entry/common.c:279 do_syscall_64+0x126/0x140 arch/x86/entry/common.c:304 entry_SYSCALL_64_after_hwframe+0x49/0xbe other info that might help us debug this: Chain exists of: &(&ctx->ctx_lock)->rlock --> &ctx->fd_wqh --> &ctx->fault_pending_wqh Possible interrupt unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&ctx->fault_pending_wqh); local_irq_disable(); lock(&(&ctx->ctx_lock)->rlock); lock(&ctx->fd_wqh); lock(&(&ctx->ctx_lock)->rlock); *** DEADLOCK *** 1 lock held by syz-executor.2/5567: #0: 0000000094949b68 (&ctx->fd_wqh){....}, at: spin_lock_irq include/linux/spinlock.h:363 [inline] #0: 0000000094949b68 (&ctx->fd_wqh){....}, at: userfaultfd_ctx_read+0x198/0x1430 fs/userfaultfd.c:1041 the dependencies between SOFTIRQ-irq-safe lock and the holding lock: -> (&(&ctx->ctx_lock)->rlock){..-.} { IN-SOFTIRQ-W at: __raw_spin_lock_irq include/linux/spinlock_api_smp.h:128 [inline] _raw_spin_lock_irq+0x6a/0x80 kernel/locking/spinlock.c:167 spin_lock_irq include/linux/spinlock.h:363 [inline] free_ioctx_users+0x33/0x1d0 fs/aio.c:620 percpu_ref_put_many include/linux/percpu-refcount.h:285 [inline] percpu_ref_put+0x1c6/0x1d0 include/linux/percpu-refcount.h:301 percpu_ref_call_confirm_rcu lib/percpu-refcount.c:124 [inline] percpu_ref_switch_to_atomic_rcu+0x260/0x310 lib/percpu-refcount.c:159 __rcu_reclaim kernel/rcu/rcu.h:222 [inline] rcu_do_batch kernel/rcu/tree.c:2092 [inline] invoke_rcu_callbacks kernel/rcu/tree.c:2310 [inline] rcu_core+0x8d6/0xf90 kernel/rcu/tree.c:2291 __do_softirq+0x340/0x7b0 arch/x86/include/asm/paravirt.h:777 run_ksoftirqd+0x64/0xf0 kernel/softirq.c:603 smpboot_thread_fn+0x62c/0xa50 kernel/smpboot.c:165 kthread+0x325/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 INITIAL USE at: __raw_spin_lock_irq include/linux/spinlock_api_smp.h:128 [inline] _raw_spin_lock_irq+0x6a/0x80 kernel/locking/spinlock.c:167 spin_lock_irq include/linux/spinlock.h:363 [inline] free_ioctx_users+0x33/0x1d0 fs/aio.c:620 percpu_ref_put_many include/linux/percpu-refcount.h:285 [inline] percpu_ref_put+0x1c6/0x1d0 include/linux/percpu-refcount.h:301 percpu_ref_call_confirm_rcu lib/percpu-refcount.c:124 [inline] percpu_ref_switch_to_atomic_rcu+0x260/0x310 lib/percpu-refcount.c:159 __rcu_reclaim kernel/rcu/rcu.h:222 [inline] rcu_do_batch kernel/rcu/tree.c:2092 [inline] invoke_rcu_callbacks kernel/rcu/tree.c:2310 [inline] rcu_core+0x8d6/0xf90 kernel/rcu/tree.c:2291 __do_softirq+0x340/0x7b0 arch/x86/include/asm/paravirt.h:777 run_ksoftirqd+0x64/0xf0 kernel/softirq.c:603 smpboot_thread_fn+0x62c/0xa50 kernel/smpboot.c:165 kthread+0x325/0x350 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 } ... key at: [] ioctx_alloc.__key+0x0/0x10 ... acquired at: __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2d/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:338 [inline] aio_poll fs/aio.c:1752 [inline] __io_submit_one fs/aio.c:1826 [inline] io_submit_one+0x1167/0x1ac0 fs/aio.c:1863 __do_sys_io_submit fs/aio.c:1922 [inline] __se_sys_io_submit+0x18f/0x2d0 fs/aio.c:1892 __x64_sys_io_submit+0x7b/0x90 fs/aio.c:1892 do_syscall_64+0xfe/0x140 arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> (&ctx->fd_wqh){....} { INITIAL USE at: __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0xa1/0xc0 kernel/locking/spinlock.c:159 __wake_up_common_lock+0x105/0x240 kernel/sched/wait.c:121 __wake_up+0xe/0x10 kernel/sched/wait.c:146 userfaultfd_release+0x53a/0x620 fs/userfaultfd.c:929 __fput+0x2e4/0x740 fs/file_table.c:280 ____fput+0x15/0x20 fs/file_table.c:313 task_work_run+0x17e/0x1b0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:185 [inline] exit_to_usermode_loop arch/x86/entry/common.c:168 [inline] prepare_exit_to_usermode+0x402/0x4f0 arch/x86/entry/common.c:199 syscall_return_slowpath+0x110/0x440 arch/x86/entry/common.c:279 do_syscall_64+0x126/0x140 arch/x86/entry/common.c:304 entry_SYSCALL_64_after_hwframe+0x49/0xbe } ... key at: [] init_once_userfaultfd_ctx.__key.15+0x0/0x10 ... acquired at: __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2d/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:338 [inline] userfaultfd_ctx_read+0x3e7/0x1430 fs/userfaultfd.c:1045 userfaultfd_read+0x15d/0x2b0 fs/userfaultfd.c:1203 __vfs_read+0xf9/0x7c0 fs/read_write.c:425 vfs_read+0x195/0x3c0 fs/read_write.c:461 ksys_read+0x16b/0x2a0 fs/read_write.c:587 __do_sys_read fs/read_write.c:597 [inline] __se_sys_read fs/read_write.c:595 [inline] __x64_sys_read+0x7b/0x90 fs/read_write.c:595 do_syscall_64+0xfe/0x140 arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe the dependencies between the lock to be acquired and SOFTIRQ-irq-unsafe lock: -> (&ctx->fault_pending_wqh){+.+.} { HARDIRQ-ON-W at: __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2d/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:338 [inline] userfaultfd_release+0x4dc/0x620 fs/userfaultfd.c:921 __fput+0x2e4/0x740 fs/file_table.c:280 ____fput+0x15/0x20 fs/file_table.c:313 task_work_run+0x17e/0x1b0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:185 [inline] exit_to_usermode_loop arch/x86/entry/common.c:168 [inline] prepare_exit_to_usermode+0x402/0x4f0 arch/x86/entry/common.c:199 syscall_return_slowpath+0x110/0x440 arch/x86/entry/common.c:279 do_syscall_64+0x126/0x140 arch/x86/entry/common.c:304 entry_SYSCALL_64_after_hwframe+0x49/0xbe SOFTIRQ-ON-W at: __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2d/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:338 [inline] userfaultfd_release+0x4dc/0x620 fs/userfaultfd.c:921 __fput+0x2e4/0x740 fs/file_table.c:280 ____fput+0x15/0x20 fs/file_table.c:313 task_work_run+0x17e/0x1b0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:185 [inline] exit_to_usermode_loop arch/x86/entry/common.c:168 [inline] prepare_exit_to_usermode+0x402/0x4f0 arch/x86/entry/common.c:199 syscall_return_slowpath+0x110/0x440 arch/x86/entry/common.c:279 do_syscall_64+0x126/0x140 arch/x86/entry/common.c:304 entry_SYSCALL_64_after_hwframe+0x49/0xbe INITIAL USE at: __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2d/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:338 [inline] userfaultfd_release+0x4dc/0x620 fs/userfaultfd.c:921 __fput+0x2e4/0x740 fs/file_table.c:280 ____fput+0x15/0x20 fs/file_table.c:313 task_work_run+0x17e/0x1b0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:185 [inline] exit_to_usermode_loop arch/x86/entry/common.c:168 [inline] prepare_exit_to_usermode+0x402/0x4f0 arch/x86/entry/common.c:199 syscall_return_slowpath+0x110/0x440 arch/x86/entry/common.c:279 do_syscall_64+0x126/0x140 arch/x86/entry/common.c:304 entry_SYSCALL_64_after_hwframe+0x49/0xbe } ... key at: [] init_once_userfaultfd_ctx.__key+0x0/0x10 ... acquired at: __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2d/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:338 [inline] userfaultfd_ctx_read+0x3e7/0x1430 fs/userfaultfd.c:1045 userfaultfd_read+0x15d/0x2b0 fs/userfaultfd.c:1203 __vfs_read+0xf9/0x7c0 fs/read_write.c:425 vfs_read+0x195/0x3c0 fs/read_write.c:461 ksys_read+0x16b/0x2a0 fs/read_write.c:587 __do_sys_read fs/read_write.c:597 [inline] __se_sys_read fs/read_write.c:595 [inline] __x64_sys_read+0x7b/0x90 fs/read_write.c:595 do_syscall_64+0xfe/0x140 arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe stack backtrace: CPU: 0 PID: 5567 Comm: syz-executor.2 Not tainted 5.2.0-rc6 #6 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1d8/0x2f8 lib/dump_stack.c:113 print_bad_irq_dependency kernel/locking/lockdep.c:1920 [inline] check_irq_usage kernel/locking/lockdep.c:2114 [inline] check_prev_add kernel/locking/lockdep.c:2315 [inline] check_prevs_add kernel/locking/lockdep.c:2418 [inline] validate_chain+0x829b/0x84f0 kernel/locking/lockdep.c:2800 __lock_acquire+0xcf7/0x1a40 kernel/locking/lockdep.c:3793 lock_acquire+0x158/0x250 kernel/locking/lockdep.c:4303 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2d/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:338 [inline] userfaultfd_ctx_read+0x3e7/0x1430 fs/userfaultfd.c:1045 userfaultfd_read+0x15d/0x2b0 fs/userfaultfd.c:1203 __vfs_read+0xf9/0x7c0 fs/read_write.c:425 vfs_read+0x195/0x3c0 fs/read_write.c:461 ksys_read+0x16b/0x2a0 fs/read_write.c:587 __do_sys_read fs/read_write.c:597 [inline] __se_sys_read fs/read_write.c:595 [inline] __x64_sys_read+0x7b/0x90 fs/read_write.c:595 do_syscall_64+0xfe/0x140 arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x459519 Code: fd b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 cb b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007f6919017c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000459519 RDX: 0000000000000064 RSI: 0000000020009f9c RDI: 0000000000000004 RBP: 000000000075bfc8 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f69190186d4 R13: 00000000004c55fd R14: 00000000004db678 R15: 00000000ffffffff