syzbot


possible deadlock in lock_mm_and_find_vma (3)

Status: upstream: reported on 2024/12/04 07:31
Subsystems: ntfs3
[Documentation on labels]
Reported-by: syzbot+936adc4458c5f973d899@syzkaller.appspotmail.com
First crash: 167d, last: 8d13h
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [ntfs3?] possible deadlock in lock_mm_and_find_vma (3) 0 (1) 2024/12/04 07:31
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in lock_mm_and_find_vma (2) mm C 6626 187d 259d 28/28 fixed on 2024/11/14 10:09
upstream possible deadlock in lock_mm_and_find_vma exfat C error 2 654d 673d 23/28 fixed on 2023/10/12 12:48

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.15.0-rc5-syzkaller-00043-gd76bb1ebb558 #0 Tainted: G     U             
------------------------------------------------------
syz.6.6032/32631 is trying to acquire lock:
ffff8880335c5be0 (&mm->mmap_lock){++++}-{4:4}, at: mmap_read_lock_killable include/linux/mmap_lock.h:193 [inline]
ffff8880335c5be0 (&mm->mmap_lock){++++}-{4:4}, at: get_mmap_lock_carefully mm/memory.c:6355 [inline]
ffff8880335c5be0 (&mm->mmap_lock){++++}-{4:4}, at: lock_mm_and_find_vma+0x3e7/0x6e0 mm/memory.c:6406

but task is already holding lock:
ffff88801c2f7948 (&root->kernfs_rwsem){++++}-{4:4}, at: kernfs_fop_readdir+0x160/0x930 fs/kernfs/dir.c:1890

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #4 (&root->kernfs_rwsem){++++}-{4:4}:
       down_read+0x9b/0x480 kernel/locking/rwsem.c:1524
       kernfs_find_and_get_ns+0x2f/0x70 fs/kernfs/dir.c:933
       kernfs_find_and_get include/linux/kernfs.h:612 [inline]
       sysfs_remove_group+0x73/0x180 fs/sysfs/group.c:311
       topology_remove_dev+0x22/0x30 drivers/base/topology.c:199
       cpuhp_invoke_callback+0x3d2/0xa10 kernel/cpu.c:194
       __cpuhp_invoke_callback_range+0x101/0x210 kernel/cpu.c:967
       cpuhp_invoke_callback_range kernel/cpu.c:991 [inline]
       cpuhp_down_callbacks kernel/cpu.c:1384 [inline]
       _cpu_down+0x422/0xf20 kernel/cpu.c:1445
       __cpu_down_maps_locked+0x6c/0x90 kernel/cpu.c:1470
       work_for_cpu_fn+0x52/0xa0 kernel/workqueue.c:6733
       process_one_work+0x9cc/0x1b70 kernel/workqueue.c:3238
       process_scheduled_works kernel/workqueue.c:3319 [inline]
       worker_thread+0x6c8/0xf10 kernel/workqueue.c:3400
       kthread+0x3c2/0x780 kernel/kthread.c:464
       ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:153
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

-> #3 (cpu_hotplug_lock){++++}-{0:0}:
       percpu_down_read include/linux/percpu-rwsem.h:52 [inline]
       cpus_read_lock+0x42/0x160 kernel/cpu.c:490
       ring_buffer_resize+0x7ea/0x1560 kernel/trace/ring_buffer.c:2894
       __tracing_resize_ring_buffer.part.0+0x52/0x1f0 kernel/trace/trace.c:5943
       __tracing_resize_ring_buffer kernel/trace/trace.c:5937 [inline]
       tracing_update_buffers+0x102/0x130 kernel/trace/trace.c:6170
       ftrace_event_write+0x14a/0x290 kernel/trace/trace_events.c:1494
       vfs_write+0x25c/0x1180 fs/read_write.c:682
       ksys_write+0x12a/0x240 fs/read_write.c:736
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xcd/0x230 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #2 (&buffer->mutex#2){+.+.}-{4:4}:
       __mutex_lock_common kernel/locking/mutex.c:601 [inline]
       __mutex_lock+0x199/0xb90 kernel/locking/mutex.c:746
       ring_buffer_map+0x144/0xa40 kernel/trace/ring_buffer.c:7157
       tracing_buffers_mmap+0x120/0x1c0 kernel/trace/trace.c:8519
       call_mmap include/linux/fs.h:2243 [inline]
       mmap_file mm/internal.h:167 [inline]
       __mmap_new_file_vma mm/vma.c:2353 [inline]
       __mmap_new_vma mm/vma.c:2417 [inline]
       __mmap_region+0x1485/0x27c0 mm/vma.c:2519
       mmap_region+0x1ab/0x3f0 mm/vma.c:2597
       do_mmap+0xd8e/0x11b0 mm/mmap.c:561
       vm_mmap_pgoff+0x281/0x450 mm/util.c:579
       ksys_mmap_pgoff+0x32c/0x5c0 mm/mmap.c:607
       __do_sys_mmap arch/x86/kernel/sys_x86_64.c:89 [inline]
       __se_sys_mmap arch/x86/kernel/sys_x86_64.c:82 [inline]
       __x64_sys_mmap+0x125/0x190 arch/x86/kernel/sys_x86_64.c:82
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xcd/0x230 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (&cpu_buffer->mapping_lock){+.+.}-{4:4}:
       __mutex_lock_common kernel/locking/mutex.c:601 [inline]
       __mutex_lock+0x199/0xb90 kernel/locking/mutex.c:746
       ring_buffer_map+0xdc/0xa40 kernel/trace/ring_buffer.c:7146
       tracing_buffers_mmap+0x120/0x1c0 kernel/trace/trace.c:8519
       call_mmap include/linux/fs.h:2243 [inline]
       mmap_file mm/internal.h:167 [inline]
       __mmap_new_file_vma mm/vma.c:2353 [inline]
       __mmap_new_vma mm/vma.c:2417 [inline]
       __mmap_region+0x1485/0x27c0 mm/vma.c:2519
       mmap_region+0x1ab/0x3f0 mm/vma.c:2597
       do_mmap+0xd8e/0x11b0 mm/mmap.c:561
       vm_mmap_pgoff+0x281/0x450 mm/util.c:579
       ksys_mmap_pgoff+0x32c/0x5c0 mm/mmap.c:607
       __do_sys_mmap arch/x86/kernel/sys_x86_64.c:89 [inline]
       __se_sys_mmap arch/x86/kernel/sys_x86_64.c:82 [inline]
       __x64_sys_mmap+0x125/0x190 arch/x86/kernel/sys_x86_64.c:82
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xcd/0x230 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&mm->mmap_lock){++++}-{4:4}:
       check_prev_add kernel/locking/lockdep.c:3166 [inline]
       check_prevs_add kernel/locking/lockdep.c:3285 [inline]
       validate_chain kernel/locking/lockdep.c:3909 [inline]
       __lock_acquire+0x1173/0x1ba0 kernel/locking/lockdep.c:5235
       lock_acquire kernel/locking/lockdep.c:5866 [inline]
       lock_acquire+0x179/0x350 kernel/locking/lockdep.c:5823
       down_read_killable+0x9e/0x4b0 kernel/locking/rwsem.c:1547
       mmap_read_lock_killable include/linux/mmap_lock.h:193 [inline]
       get_mmap_lock_carefully mm/memory.c:6355 [inline]
       lock_mm_and_find_vma+0x3e7/0x6e0 mm/memory.c:6406
       do_user_addr_fault+0x2ac/0x1370 arch/x86/mm/fault.c:1360
       handle_page_fault arch/x86/mm/fault.c:1480 [inline]
       exc_page_fault+0x5c/0xc0 arch/x86/mm/fault.c:1538
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623
       filldir+0x29c/0x5f0 fs/readdir.c:290
       dir_emit include/linux/fs.h:3861 [inline]
       kernfs_fop_readdir+0x3d5/0x930 fs/kernfs/dir.c:1907
       iterate_dir+0x293/0xb40 fs/readdir.c:108
       __do_sys_getdents fs/readdir.c:322 [inline]
       __se_sys_getdents fs/readdir.c:308 [inline]
       __x64_sys_getdents+0x14d/0x2c0 fs/readdir.c:308
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0xcd/0x230 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

Chain exists of:
  &mm->mmap_lock --> cpu_hotplug_lock --> &root->kernfs_rwsem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(&root->kernfs_rwsem);
                               lock(cpu_hotplug_lock);
                               lock(&root->kernfs_rwsem);
  rlock(&mm->mmap_lock);

 *** DEADLOCK ***

3 locks held by syz.6.6032/32631:
 #0: ffff88802fd69eb8 (&f->f_pos_lock){+.+.}-{4:4}, at: fdget_pos+0x2a2/0x370 fs/file.c:1213
 #1: ffff888076475060 (&type->i_mutex_dir_key#6){++++}-{4:4}, at: iterate_dir+0x18b/0xb40 fs/readdir.c:101
 #2: ffff88801c2f7948 (&root->kernfs_rwsem){++++}-{4:4}, at: kernfs_fop_readdir+0x160/0x930 fs/kernfs/dir.c:1890

stack backtrace:
CPU: 1 UID: 0 PID: 32631 Comm: syz.6.6032 Tainted: G     U              6.15.0-rc5-syzkaller-00043-gd76bb1ebb558 #0 PREEMPT(full) 
Tainted: [U]=USER
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/29/2025
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_circular_bug+0x275/0x350 kernel/locking/lockdep.c:2079
 check_noncircular+0x14c/0x170 kernel/locking/lockdep.c:2211
 check_prev_add kernel/locking/lockdep.c:3166 [inline]
 check_prevs_add kernel/locking/lockdep.c:3285 [inline]
 validate_chain kernel/locking/lockdep.c:3909 [inline]
 __lock_acquire+0x1173/0x1ba0 kernel/locking/lockdep.c:5235
 lock_acquire kernel/locking/lockdep.c:5866 [inline]
 lock_acquire+0x179/0x350 kernel/locking/lockdep.c:5823
 down_read_killable+0x9e/0x4b0 kernel/locking/rwsem.c:1547
 mmap_read_lock_killable include/linux/mmap_lock.h:193 [inline]
 get_mmap_lock_carefully mm/memory.c:6355 [inline]
 lock_mm_and_find_vma+0x3e7/0x6e0 mm/memory.c:6406
 do_user_addr_fault+0x2ac/0x1370 arch/x86/mm/fault.c:1360
 handle_page_fault arch/x86/mm/fault.c:1480 [inline]
 exc_page_fault+0x5c/0xc0 arch/x86/mm/fault.c:1538
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623
RIP: 0010:filldir+0x29c/0x5f0 fs/readdir.c:290
Code: db e8 58 31 84 ff 89 d8 48 83 c4 50 5b 5d 41 5c 41 5d 41 5e 41 5f c3 cc cc cc cc e8 3e 31 84 ff 0f 01 cb 0f ae e8 48 8b 04 24 <49> 89 47 08 e8 2b 31 84 ff 4c 8b 7c 24 30 48 8b 44 24 10 49 89 07
RSP: 0018:ffffc9000b167cd8 EFLAGS: 00050293
RAX: 000000004127eee8 RBX: ffffc9000b167e80 RCX: ffffffff82367b3a
RDX: ffff88802e525a00 RSI: ffffffff82367b92 RDI: 0000000000000006
RBP: 0000000000000268 R08: 0000000000000006 R09: 0000000000000218
R10: 0000000000000268 R11: 0000000000000000 R12: 000000000000000e
R13: 0000000000000028 R14: ffff888078a86d00 R15: 0000000000000218
 dir_emit include/linux/fs.h:3861 [inline]
 kernfs_fop_readdir+0x3d5/0x930 fs/kernfs/dir.c:1907
 iterate_dir+0x293/0xb40 fs/readdir.c:108
 __do_sys_getdents fs/readdir.c:322 [inline]
 __se_sys_getdents fs/readdir.c:308 [inline]
 __x64_sys_getdents+0x14d/0x2c0 fs/readdir.c:308
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xcd/0x230 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fb1cb38e969
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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fb1c91f6038 EFLAGS: 00000246 ORIG_RAX: 000000000000004e
RAX: ffffffffffffffda RBX: 00007fb1cb5b6160 RCX: 00007fb1cb38e969
RDX: 0000000000400018 RSI: 0000000000000000 RDI: 000000000000006b
RBP: 00007fb1cb410ab1 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fb1cb5b6160 R15: 00007fff6d727d08
 </TASK>
----------------
Code disassembly (best guess), 1 bytes skipped:
   0:	e8 58 31 84 ff       	call   0xff84315d
   5:	89 d8                	mov    %ebx,%eax
   7:	48 83 c4 50          	add    $0x50,%rsp
   b:	5b                   	pop    %rbx
   c:	5d                   	pop    %rbp
   d:	41 5c                	pop    %r12
   f:	41 5d                	pop    %r13
  11:	41 5e                	pop    %r14
  13:	41 5f                	pop    %r15
  15:	c3                   	ret
  16:	cc                   	int3
  17:	cc                   	int3
  18:	cc                   	int3
  19:	cc                   	int3
  1a:	e8 3e 31 84 ff       	call   0xff84315d
  1f:	0f 01 cb             	stac
  22:	0f ae e8             	lfence
  25:	48 8b 04 24          	mov    (%rsp),%rax
* 29:	49 89 47 08          	mov    %rax,0x8(%r15) <-- trapping instruction
  2d:	e8 2b 31 84 ff       	call   0xff84315d
  32:	4c 8b 7c 24 30       	mov    0x30(%rsp),%r15
  37:	48 8b 44 24 10       	mov    0x10(%rsp),%rax
  3c:	49 89 07             	mov    %rax,(%r15)

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/05/08 17:36 upstream d76bb1ebb558 dbf35fa1 .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto possible deadlock in lock_mm_and_find_vma
2025/04/16 03:25 upstream 1a1d569a75f3 23b969b7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root possible deadlock in lock_mm_and_find_vma
2025/04/14 01:03 upstream 8ffd015db85f 0bd6db41 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root possible deadlock in lock_mm_and_find_vma
2025/01/07 06:36 upstream fbfd64d25c7a f3558dbf .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root possible deadlock in lock_mm_and_find_vma
2024/11/30 07:29 upstream 509f806f7f70 68914665 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root possible deadlock in lock_mm_and_find_vma
* Struck through repros no longer work on HEAD.