===================================================== WARNING: SOFTIRQ-safe -> SOFTIRQ-unsafe lock order detected 5.2.0-rc6+ #7 Not tainted ----------------------------------------------------- syz-executor.4/358 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire: 000000000b6d8a2c (&ctx->fault_pending_wqh){+.+.}, at: spin_lock include/linux/spinlock.h:338 [inline] 000000000b6d8a2c (&ctx->fault_pending_wqh){+.+.}, at: userfaultfd_ctx_read+0x3e7/0x1430 fs/userfaultfd.c:1045 and this task is already holding: 00000000af5c0164 (&ctx->fd_wqh){....}, at: spin_lock_irq include/linux/spinlock.h:363 [inline] 00000000af5c0164 (&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 invoke_softirq kernel/softirq.c:373 [inline] irq_exit+0x21a/0x230 kernel/softirq.c:413 exiting_irq arch/x86/include/asm/apic.h:536 [inline] smp_apic_timer_interrupt+0xf8/0x260 arch/x86/kernel/apic/apic.c:1068 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:806 arch_local_irq_restore arch/x86/include/asm/paravirt.h:767 [inline] lock_acquire+0x1b2/0x250 kernel/locking/lockdep.c:4306 __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] lockref_put_or_lock+0x27/0xc0 lib/lockref.c:174 fast_dput fs/dcache.c:728 [inline] dput+0x2dd/0x450 fs/dcache.c:846 path_put fs/namei.c:482 [inline] do_unlinkat+0x6d5/0x920 fs/namei.c:4076 __do_sys_unlink fs/namei.c:4108 [inline] __se_sys_unlink fs/namei.c:4106 [inline] __x64_sys_unlink+0x49/0x50 fs/namei.c:4106 do_syscall_64+0xfe/0x140 arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe 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] handle_userfault+0x624/0x1690 fs/userfaultfd.c:461 shmem_getpage_gfp+0x2977/0x2dd0 mm/shmem.c:1786 shmem_fault+0x28f/0x780 mm/shmem.c:2048 __do_fault+0x154/0x390 mm/memory.c:3127 do_read_fault mm/memory.c:3537 [inline] do_fault mm/memory.c:3666 [inline] handle_pte_fault mm/memory.c:3897 [inline] __handle_mm_fault mm/memory.c:4021 [inline] handle_mm_fault+0x4430/0x6130 mm/memory.c:4058 do_user_addr_fault+0x56f/0xaa0 arch/x86/mm/fault.c:1457 __do_page_fault+0xd3/0x1f0 arch/x86/mm/fault.c:1523 do_page_fault+0xce/0xe0 arch/x86/mm/fault.c:1554 page_fault+0x1e/0x30 arch/x86/entry/entry_64.S:1156 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.4/358: #0: 00000000af5c0164 (&ctx->fd_wqh){....}, at: spin_lock_irq include/linux/spinlock.h:363 [inline] #0: 00000000af5c0164 (&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 invoke_softirq kernel/softirq.c:373 [inline] irq_exit+0x21a/0x230 kernel/softirq.c:413 exiting_irq arch/x86/include/asm/apic.h:536 [inline] smp_apic_timer_interrupt+0xf8/0x260 arch/x86/kernel/apic/apic.c:1068 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:806 arch_local_irq_restore arch/x86/include/asm/paravirt.h:767 [inline] lock_acquire+0x1b2/0x250 kernel/locking/lockdep.c:4306 __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] lockref_put_or_lock+0x27/0xc0 lib/lockref.c:174 fast_dput fs/dcache.c:728 [inline] dput+0x2dd/0x450 fs/dcache.c:846 path_put fs/namei.c:482 [inline] do_unlinkat+0x6d5/0x920 fs/namei.c:4076 __do_sys_unlink fs/namei.c:4108 [inline] __se_sys_unlink fs/namei.c:4106 [inline] __x64_sys_unlink+0x49/0x50 fs/namei.c:4106 do_syscall_64+0xfe/0x140 arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe 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 invoke_softirq kernel/softirq.c:373 [inline] irq_exit+0x21a/0x230 kernel/softirq.c:413 exiting_irq arch/x86/include/asm/apic.h:536 [inline] smp_apic_timer_interrupt+0xf8/0x260 arch/x86/kernel/apic/apic.c:1068 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:806 arch_local_irq_restore arch/x86/include/asm/paravirt.h:767 [inline] lock_acquire+0x1b2/0x250 kernel/locking/lockdep.c:4306 __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] lockref_put_or_lock+0x27/0xc0 lib/lockref.c:174 fast_dput fs/dcache.c:728 [inline] dput+0x2dd/0x450 fs/dcache.c:846 path_put fs/namei.c:482 [inline] do_unlinkat+0x6d5/0x920 fs/namei.c:4076 __do_sys_unlink fs/namei.c:4108 [inline] __se_sys_unlink fs/namei.c:4106 [inline] __x64_sys_unlink+0x49/0x50 fs/namei.c:4106 do_syscall_64+0xfe/0x140 arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe } ... 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 handle_userfault+0xb18/0x1690 fs/userfaultfd.c:487 shmem_getpage_gfp+0x2977/0x2dd0 mm/shmem.c:1786 shmem_fault+0x28f/0x780 mm/shmem.c:2048 __do_fault+0x154/0x390 mm/memory.c:3127 do_read_fault mm/memory.c:3537 [inline] do_fault mm/memory.c:3666 [inline] handle_pte_fault mm/memory.c:3897 [inline] __handle_mm_fault mm/memory.c:4021 [inline] handle_mm_fault+0x4430/0x6130 mm/memory.c:4058 do_user_addr_fault+0x56f/0xaa0 arch/x86/mm/fault.c:1457 __do_page_fault+0xd3/0x1f0 arch/x86/mm/fault.c:1523 do_page_fault+0xce/0xe0 arch/x86/mm/fault.c:1554 page_fault+0x1e/0x30 arch/x86/entry/entry_64.S:1156 } ... 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 do_loop_readv_writev fs/read_write.c:714 [inline] do_iter_read+0x4b1/0x5b0 fs/read_write.c:935 vfs_readv fs/read_write.c:997 [inline] do_readv+0x213/0x410 fs/read_write.c:1034 __do_sys_readv fs/read_write.c:1125 [inline] __se_sys_readv fs/read_write.c:1122 [inline] __x64_sys_readv+0x7d/0x90 fs/read_write.c:1122 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] handle_userfault+0x624/0x1690 fs/userfaultfd.c:461 shmem_getpage_gfp+0x2977/0x2dd0 mm/shmem.c:1786 shmem_fault+0x28f/0x780 mm/shmem.c:2048 __do_fault+0x154/0x390 mm/memory.c:3127 do_read_fault mm/memory.c:3537 [inline] do_fault mm/memory.c:3666 [inline] handle_pte_fault mm/memory.c:3897 [inline] __handle_mm_fault mm/memory.c:4021 [inline] handle_mm_fault+0x4430/0x6130 mm/memory.c:4058 do_user_addr_fault+0x56f/0xaa0 arch/x86/mm/fault.c:1457 __do_page_fault+0xd3/0x1f0 arch/x86/mm/fault.c:1523 do_page_fault+0xce/0xe0 arch/x86/mm/fault.c:1554 page_fault+0x1e/0x30 arch/x86/entry/entry_64.S:1156 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] handle_userfault+0x624/0x1690 fs/userfaultfd.c:461 shmem_getpage_gfp+0x2977/0x2dd0 mm/shmem.c:1786 shmem_fault+0x28f/0x780 mm/shmem.c:2048 __do_fault+0x154/0x390 mm/memory.c:3127 do_read_fault mm/memory.c:3537 [inline] do_fault mm/memory.c:3666 [inline] handle_pte_fault mm/memory.c:3897 [inline] __handle_mm_fault mm/memory.c:4021 [inline] handle_mm_fault+0x4430/0x6130 mm/memory.c:4058 do_user_addr_fault+0x56f/0xaa0 arch/x86/mm/fault.c:1457 __do_page_fault+0xd3/0x1f0 arch/x86/mm/fault.c:1523 do_page_fault+0xce/0xe0 arch/x86/mm/fault.c:1554 page_fault+0x1e/0x30 arch/x86/entry/entry_64.S:1156 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] handle_userfault+0x624/0x1690 fs/userfaultfd.c:461 shmem_getpage_gfp+0x2977/0x2dd0 mm/shmem.c:1786 shmem_fault+0x28f/0x780 mm/shmem.c:2048 __do_fault+0x154/0x390 mm/memory.c:3127 do_read_fault mm/memory.c:3537 [inline] do_fault mm/memory.c:3666 [inline] handle_pte_fault mm/memory.c:3897 [inline] __handle_mm_fault mm/memory.c:4021 [inline] handle_mm_fault+0x4430/0x6130 mm/memory.c:4058 do_user_addr_fault+0x56f/0xaa0 arch/x86/mm/fault.c:1457 __do_page_fault+0xd3/0x1f0 arch/x86/mm/fault.c:1523 do_page_fault+0xce/0xe0 arch/x86/mm/fault.c:1554 page_fault+0x1e/0x30 arch/x86/entry/entry_64.S:1156 } ... 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 do_loop_readv_writev fs/read_write.c:714 [inline] do_iter_read+0x4b1/0x5b0 fs/read_write.c:935 vfs_readv fs/read_write.c:997 [inline] do_readv+0x213/0x410 fs/read_write.c:1034 __do_sys_readv fs/read_write.c:1125 [inline] __se_sys_readv fs/read_write.c:1122 [inline] __x64_sys_readv+0x7d/0x90 fs/read_write.c:1122 do_syscall_64+0xfe/0x140 arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe stack backtrace: CPU: 1 PID: 358 Comm: syz-executor.4 Not tainted 5.2.0-rc6+ #7 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 do_loop_readv_writev fs/read_write.c:714 [inline] do_iter_read+0x4b1/0x5b0 fs/read_write.c:935 vfs_readv fs/read_write.c:997 [inline] do_readv+0x213/0x410 fs/read_write.c:1034 __do_sys_readv fs/read_write.c:1125 [inline] __se_sys_readv fs/read_write.c:1122 [inline] __x64_sys_readv+0x7d/0x90 fs/read_write.c:1122 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:00007fedf3abbc78 EFLAGS: 00000246 ORIG_RAX: 0000000000000013 RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000459519 RDX: 0000000000000001 RSI: 0000000020000000 RDI: 0000000000000003 RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007fedf3abc6d4 R13: 00000000004c664d R14: 00000000004db780 R15: 00000000ffffffff