bisecting fixing commit since 7d2a07b769330c34b4deabeed939325c77a7ec2f building syzkaller on 8f58a0efbf867526a0adee8d9a5cb38e2ebf1ee4 testing commit 7d2a07b769330c34b4deabeed939325c77a7ec2f compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: ec89a8b943d0d71e7440cf8b77e01238a6bbac68f4ed0539b5fec748963b16af all runs: crashed: possible deadlock in vm_mmap_pgoff testing current HEAD a33f5c380c4bd3fa5278d690421b72052456d9fe testing commit a33f5c380c4bd3fa5278d690421b72052456d9fe compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: d395027c6f365c182e7212c675260e6ae4ea9224f83bc5c41c05bb7a2c5b5913 all runs: crashed: possible deadlock in vm_mmap_pgoff revisions tested: 2, total time: 19m53.707044133s (build: 12m38.387377904s, test: 6m40.912737189s) the crash still happens on HEAD commit msg: Merge tag 'xfs-5.17-merge-3' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux crash: possible deadlock in vm_mmap_pgoff ====================================================== WARNING: possible circular locking dependency detected 5.16.0-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.0/4178 is trying to acquire lock: ffffffff8abe9b68 (event_mutex){+.+.}-{3:3}, at: perf_trace_destroy+0x17/0xf0 kernel/trace/trace_event_perf.c:241 but task is already holding lock: ffff88801cc0f828 (&mm->mmap_lock#2){++++}-{3:3}, at: mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline] ffff88801cc0f828 (&mm->mmap_lock#2){++++}-{3:3}, at: vm_mmap_pgoff+0x12e/0x210 mm/util.c:517 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 (&mm->mmap_lock#2){++++}-{3:3}: down_write_killable+0x93/0x170 kernel/locking/rwsem.c:1525 mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline] dup_mmap kernel/fork.c:498 [inline] dup_mm+0x10d/0x10d0 kernel/fork.c:1450 copy_mm kernel/fork.c:1502 [inline] copy_process+0x55e1/0x67f0 kernel/fork.c:2165 kernel_clone+0xb8/0x7f0 kernel/fork.c:2556 __do_sys_clone+0xaf/0xf0 kernel/fork.c:2673 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae -> #2 (dup_mmap_sem){++++}-{0:0}: percpu_down_write+0x4d/0x3e0 kernel/locking/percpu-rwsem.c:217 register_for_each_vma+0x2f/0xa80 kernel/events/uprobes.c:1042 __uprobe_register+0x4e4/0x740 kernel/events/uprobes.c:1183 trace_uprobe_enable kernel/trace/trace_uprobe.c:1066 [inline] probe_event_enable+0x2a5/0x910 kernel/trace/trace_uprobe.c:1135 perf_trace_event_reg kernel/trace/trace_event_perf.c:129 [inline] perf_trace_event_init+0x429/0x8a0 kernel/trace/trace_event_perf.c:204 perf_uprobe_init+0x10b/0x180 kernel/trace/trace_event_perf.c:336 perf_uprobe_event_init+0xbd/0x150 kernel/events/core.c:9966 perf_try_init_event+0xf6/0x470 kernel/events/core.c:11273 perf_init_event kernel/events/core.c:11337 [inline] perf_event_alloc+0xde3/0x3240 kernel/events/core.c:11628 __do_sys_perf_event_open+0x26d/0x23e0 kernel/events/core.c:12149 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae -> #1 (&uprobe->register_rwsem){+.+.}-{3:3}: down_write+0x90/0x150 kernel/locking/rwsem.c:1514 __uprobe_register+0x46b/0x740 kernel/events/uprobes.c:1179 trace_uprobe_enable kernel/trace/trace_uprobe.c:1066 [inline] probe_event_enable+0x2a5/0x910 kernel/trace/trace_uprobe.c:1135 perf_trace_event_reg kernel/trace/trace_event_perf.c:129 [inline] perf_trace_event_init+0x429/0x8a0 kernel/trace/trace_event_perf.c:204 perf_uprobe_init+0x10b/0x180 kernel/trace/trace_event_perf.c:336 perf_uprobe_event_init+0xbd/0x150 kernel/events/core.c:9966 perf_try_init_event+0xf6/0x470 kernel/events/core.c:11273 perf_init_event kernel/events/core.c:11337 [inline] perf_event_alloc+0xde3/0x3240 kernel/events/core.c:11628 __do_sys_perf_event_open+0x26d/0x23e0 kernel/events/core.c:12149 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae -> #0 (event_mutex){+.+.}-{3:3}: check_prev_add kernel/locking/lockdep.c:3063 [inline] check_prevs_add kernel/locking/lockdep.c:3186 [inline] validate_chain kernel/locking/lockdep.c:3801 [inline] __lock_acquire+0x29aa/0x5410 kernel/locking/lockdep.c:5027 lock_acquire kernel/locking/lockdep.c:5639 [inline] lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5604 __mutex_lock_common kernel/locking/mutex.c:600 [inline] __mutex_lock+0x12f/0x12f0 kernel/locking/mutex.c:733 perf_trace_destroy+0x17/0xf0 kernel/trace/trace_event_perf.c:241 _free_event+0x29b/0x1000 kernel/events/core.c:4986 put_event kernel/events/core.c:5080 [inline] perf_mmap_close+0x44b/0xb70 kernel/events/core.c:6139 remove_vma+0x9b/0x140 mm/mmap.c:184 remove_vma_list mm/mmap.c:2628 [inline] __do_munmap+0x553/0x1010 mm/mmap.c:2886 do_munmap mm/mmap.c:2894 [inline] munmap_vma_range mm/mmap.c:603 [inline] mmap_region+0x257/0x13f0 mm/mmap.c:1741 do_mmap+0x5ca/0xd80 mm/mmap.c:1575 vm_mmap_pgoff+0x163/0x210 mm/util.c:519 ksys_mmap_pgoff+0x2e8/0x490 mm/mmap.c:1623 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae other info that might help us debug this: Chain exists of: event_mutex --> dup_mmap_sem --> &mm->mmap_lock#2 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&mm->mmap_lock#2); lock(dup_mmap_sem); lock(&mm->mmap_lock#2); lock(event_mutex); *** DEADLOCK *** 1 lock held by syz-executor.0/4178: #0: ffff88801cc0f828 (&mm->mmap_lock#2){++++}-{3:3}, at: mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline] #0: ffff88801cc0f828 (&mm->mmap_lock#2){++++}-{3:3}, at: vm_mmap_pgoff+0x12e/0x210 mm/util.c:517 stack backtrace: CPU: 0 PID: 4178 Comm: syz-executor.0 Not tainted 5.16.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x57/0x7d lib/dump_stack.c:106 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2143 check_prev_add kernel/locking/lockdep.c:3063 [inline] check_prevs_add kernel/locking/lockdep.c:3186 [inline] validate_chain kernel/locking/lockdep.c:3801 [inline] __lock_acquire+0x29aa/0x5410 kernel/locking/lockdep.c:5027 lock_acquire kernel/locking/lockdep.c:5639 [inline] lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5604 __mutex_lock_common kernel/locking/mutex.c:600 [inline] __mutex_lock+0x12f/0x12f0 kernel/locking/mutex.c:733 perf_trace_destroy+0x17/0xf0 kernel/trace/trace_event_perf.c:241 _free_event+0x29b/0x1000 kernel/events/core.c:4986 put_event kernel/events/core.c:5080 [inline] perf_mmap_close+0x44b/0xb70 kernel/events/core.c:6139 remove_vma+0x9b/0x140 mm/mmap.c:184 remove_vma_list mm/mmap.c:2628 [inline] __do_munmap+0x553/0x1010 mm/mmap.c:2886 do_munmap mm/mmap.c:2894 [inline] munmap_vma_range mm/mmap.c:603 [inline] mmap_region+0x257/0x13f0 mm/mmap.c:1741 do_mmap+0x5ca/0xd80 mm/mmap.c:1575 vm_mmap_pgoff+0x163/0x210 mm/util.c:519 ksys_mmap_pgoff+0x2e8/0x490 mm/mmap.c:1623 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x4665f9 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f38b4b29188 EFLAGS: 00000246 ORIG_RAX: 0000000000000009 RAX: ffffffffffffffda RBX: 000000000056c0f0 RCX: 00000000004665f9 RDX: 0000000000000000 RSI: 0000000000003000 RDI: 0000000020ffc000 RBP: 00000000004bfcc4 R08: 0000000000000006 R09: 0000000000000000 R10: 0000000000000011 R11: 0000000000000246 R12: 000000000056c0f0 R13: 00007fff6c6e426f R14: 00007f38b4b29300 R15: 0000000000022000