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 8ab774587903771821b59471cc723bba6d893942 testing commit 8ab774587903771821b59471cc723bba6d893942 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 82f2c1cdeae034c9fe73f569a2529c530ff070c61072ab5c5fe40db533df7509 all runs: crashed: possible deadlock in vm_mmap_pgoff revisions tested: 2, total time: 21m7.348209625s (build: 13m6.616335668s, test: 7m21.870813289s) the crash still happens on HEAD commit msg: Merge tag 'trace-v5.16-5' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace crash: possible deadlock in vm_mmap_pgoff ====================================================== WARNING: possible circular locking dependency detected 5.16.0-rc1-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.4/9306 is trying to acquire lock: ffffffff8ade7908 (event_mutex){+.+.}-{3:3}, at: perf_trace_destroy+0x17/0xf0 kernel/trace/trace_event_perf.c:241 but task is already holding lock: ffff88806e4d8228 (&mm->mmap_lock#2){++++}-{3:3}, at: mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline] ffff88806e4d8228 (&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:1538 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+0x67d7/0x6a50 kernel/fork.c:2191 kernel_clone+0xb8/0x7f0 kernel/fork.c:2582 __do_sys_clone+0xaf/0xf0 kernel/fork.c:2699 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:1065 [inline] probe_event_enable+0x2a5/0x910 kernel/trace/trace_uprobe.c:1134 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:9942 perf_try_init_event+0xf6/0x470 kernel/events/core.c:11249 perf_init_event kernel/events/core.c:11313 [inline] perf_event_alloc+0xde6/0x31f0 kernel/events/core.c:11604 __do_sys_perf_event_open+0x26d/0x23e0 kernel/events/core.c:12125 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:1527 __uprobe_register+0x46b/0x740 kernel/events/uprobes.c:1179 trace_uprobe_enable kernel/trace/trace_uprobe.c:1065 [inline] probe_event_enable+0x2a5/0x910 kernel/trace/trace_uprobe.c:1134 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:9942 perf_try_init_event+0xf6/0x470 kernel/events/core.c:11249 perf_init_event kernel/events/core.c:11313 [inline] perf_event_alloc+0xde6/0x31f0 kernel/events/core.c:11604 __do_sys_perf_event_open+0x26d/0x23e0 kernel/events/core.c:12125 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+0x2985/0x5410 kernel/locking/lockdep.c:5027 lock_acquire kernel/locking/lockdep.c:5637 [inline] lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5602 __mutex_lock_common kernel/locking/mutex.c:607 [inline] __mutex_lock+0x12f/0x12f0 kernel/locking/mutex.c:740 perf_trace_destroy+0x17/0xf0 kernel/trace/trace_event_perf.c:241 _free_event+0x29b/0x1000 kernel/events/core.c:4982 put_event kernel/events/core.c:5076 [inline] perf_mmap_close+0x44b/0xb70 kernel/events/core.c:6135 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/0x1480 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.4/9306: #0: ffff88806e4d8228 (&mm->mmap_lock#2){++++}-{3:3}, at: mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline] #0: ffff88806e4d8228 (&mm->mmap_lock#2){++++}-{3:3}, at: vm_mmap_pgoff+0x12e/0x210 mm/util.c:517 stack backtrace: CPU: 0 PID: 9306 Comm: syz-executor.4 Not tainted 5.16.0-rc1-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+0x2985/0x5410 kernel/locking/lockdep.c:5027 lock_acquire kernel/locking/lockdep.c:5637 [inline] lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5602 __mutex_lock_common kernel/locking/mutex.c:607 [inline] __mutex_lock+0x12f/0x12f0 kernel/locking/mutex.c:740 perf_trace_destroy+0x17/0xf0 kernel/trace/trace_event_perf.c:241 _free_event+0x29b/0x1000 kernel/events/core.c:4982 put_event kernel/events/core.c:5076 [inline] perf_mmap_close+0x44b/0xb70 kernel/events/core.c:6135 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/0x1480 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:00007f772fc1c188 EFLAGS: 00000246 ORIG_RAX: 0000000000000009 RAX: ffffffffffffffda RBX: 000000000056c1a8 RCX: 00000000004665f9 RDX: 0000000000000000 RSI: 0000000000003000 RDI: 0000000020ffc000 RBP: 00000000004bfcc4 R08: 0000000000000006 R09: 0000000000000000 R10: 0000000000000011 R11: 0000000000000246 R12: 000000000056c1a8 R13: 00007ffdebb6f09f R14: 00007f772fc1c300 R15: 0000000000022000