syzbot


possible deadlock in filemap_fault (2)

Status: upstream: reported on 2023/12/22 21:26
Reported-by: syzbot+b114e607666a3a11a128@syzkaller.appspotmail.com
First crash: 150d, last: 2d22h
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 possible deadlock in filemap_fault 84 255d 430d 0/3 auto-obsoleted due to no activity on 2023/11/17 20:19
upstream possible deadlock in filemap_fault mm ntfs3 C done 1031 3h45m 564d 0/26 upstream: reported C repro on 2022/11/03 22:14
linux-6.1 possible deadlock in filemap_fault 192 257d 432d 0/3 auto-obsoleted due to no activity on 2023/11/15 23:38
linux-5.15 possible deadlock in filemap_fault (2) origin:upstream C 15 11d 44d 0/3 upstream: reported C repro on 2024/04/06 04:54

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.91-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/10330 is trying to acquire lock:
ffff888058c59400 (mapping.invalidate_lock#11){++++}-{3:3}, at: filemap_invalidate_lock_shared include/linux/fs.h:813 [inline]
ffff888058c59400 (mapping.invalidate_lock#11){++++}-{3:3}, at: filemap_fault+0x640/0x17e0 mm/filemap.c:3191

but task is already holding lock:
ffff8880223cf1d8 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_trylock include/linux/mmap_lock.h:136 [inline]
ffff8880223cf1d8 (&mm->mmap_lock){++++}-{3:3}, at: get_mmap_lock_carefully mm/memory.c:5304 [inline]
ffff8880223cf1d8 (&mm->mmap_lock){++++}-{3:3}, at: lock_mm_and_find_vma+0x2e/0x2e0 mm/memory.c:5366

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&mm->mmap_lock){++++}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __might_fault+0xbd/0x110 mm/memory.c:5835
       _copy_to_user+0x26/0x130 lib/usercopy.c:36
       copy_to_user include/linux/uaccess.h:169 [inline]
       fiemap_fill_next_extent+0x231/0x410 fs/ioctl.c:144
       ni_fiemap+0xa5a/0x1230 fs/ntfs3/frecord.c:2066
       ntfs_fiemap+0x12e/0x170 fs/ntfs3/file.c:1247
       ioctl_fiemap fs/ioctl.c:219 [inline]
       do_vfs_ioctl+0x18e9/0x2a90 fs/ioctl.c:810
       __do_sys_ioctl fs/ioctl.c:868 [inline]
       __se_sys_ioctl+0x81/0x160 fs/ioctl.c:856
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #1 (&ni->file.run_lock#3){++++}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       down_read+0xad/0xa30 kernel/locking/rwsem.c:1520
       attr_data_get_block+0x276/0x2520 fs/ntfs3/attrib.c:903
       ntfs_get_block_vbo+0x373/0xe60 fs/ntfs3/inode.c:590
       __mpage_writepage+0x40d/0x1930 fs/mpage.c:533
       write_cache_pages+0x92e/0x15c0 mm/page-writeback.c:2360
       mpage_writepages+0x103/0x1d0 fs/mpage.c:664
       do_writepages+0x3a2/0x670 mm/page-writeback.c:2469
       filemap_fdatawrite_wbc+0x121/0x180 mm/filemap.c:388
       __filemap_fdatawrite_range mm/filemap.c:421 [inline]
       filemap_write_and_wait_range+0x1a4/0x290 mm/filemap.c:674
       ntfs_fallocate+0x401/0x1020 fs/ntfs3/file.c:591
       vfs_fallocate+0x547/0x6b0 fs/open.c:323
       ksys_fallocate fs/open.c:346 [inline]
       __do_sys_fallocate fs/open.c:354 [inline]
       __se_sys_fallocate fs/open.c:352 [inline]
       __x64_sys_fallocate+0xb9/0x100 fs/open.c:352
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #0 (mapping.invalidate_lock#11){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       down_read+0xad/0xa30 kernel/locking/rwsem.c:1520
       filemap_invalidate_lock_shared include/linux/fs.h:813 [inline]
       filemap_fault+0x640/0x17e0 mm/filemap.c:3191
       __do_fault+0x136/0x4f0 mm/memory.c:4261
       do_read_fault mm/memory.c:4612 [inline]
       do_fault mm/memory.c:4741 [inline]
       handle_pte_fault mm/memory.c:5013 [inline]
       __handle_mm_fault mm/memory.c:5155 [inline]
       handle_mm_fault+0x3412/0x5340 mm/memory.c:5276
       do_user_addr_fault arch/x86/mm/fault.c:1371 [inline]
       handle_page_fault arch/x86/mm/fault.c:1462 [inline]
       exc_page_fault+0x26f/0x660 arch/x86/mm/fault.c:1518
       asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570
       copy_user_enhanced_fast_string+0xa/0x40 arch/x86/lib/copy_user_64.S:165
       copy_user_generic arch/x86/include/asm/uaccess_64.h:37 [inline]
       raw_copy_from_user arch/x86/include/asm/uaccess_64.h:52 [inline]
       copyin+0xd8/0x120 lib/iov_iter.c:183
       _copy_from_iter+0x493/0xff0 lib/iov_iter.c:631
       copy_from_iter include/linux/uio.h:187 [inline]
       copy_from_iter_full include/linux/uio.h:194 [inline]
       memcpy_from_msg include/linux/skbuff.h:4004 [inline]
       virtio_transport_alloc_skb+0x4b0/0x1220 net/vmw_vsock/virtio_transport_common.c:76
       virtio_transport_send_pkt_info+0x2d4/0x6f0 net/vmw_vsock/virtio_transport_common.c:237
       virtio_transport_stream_enqueue+0x151/0x1f0 net/vmw_vsock/virtio_transport_common.c:821
       vsock_connectible_sendmsg+0xa01/0xde0 net/vmw_vsock/af_vsock.c:1864
       sock_sendmsg_nosec net/socket.c:718 [inline]
       __sock_sendmsg net/socket.c:730 [inline]
       sock_write_iter+0x394/0x4e0 net/socket.c:1143
       do_iter_write+0x6e6/0xc50 fs/read_write.c:861
       vfs_writev fs/read_write.c:934 [inline]
       do_writev+0x27b/0x460 fs/read_write.c:977
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

other info that might help us debug this:

Chain exists of:
  mapping.invalidate_lock#11 --> &ni->file.run_lock#3 --> &mm->mmap_lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&mm->mmap_lock);
                               lock(&ni->file.run_lock#3);
                               lock(&mm->mmap_lock);
  lock(mapping.invalidate_lock#11);

 *** DEADLOCK ***

2 locks held by syz-executor.0/10330:
 #0: ffff888064279ab0 (sk_lock-AF_VSOCK){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1748 [inline]
 #0: ffff888064279ab0 (sk_lock-AF_VSOCK){+.+.}-{0:0}, at: vsock_connectible_sendmsg+0x210/0xde0 net/vmw_vsock/af_vsock.c:1763
 #1: ffff8880223cf1d8 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_trylock include/linux/mmap_lock.h:136 [inline]
 #1: ffff8880223cf1d8 (&mm->mmap_lock){++++}-{3:3}, at: get_mmap_lock_carefully mm/memory.c:5304 [inline]
 #1: ffff8880223cf1d8 (&mm->mmap_lock){++++}-{3:3}, at: lock_mm_and_find_vma+0x2e/0x2e0 mm/memory.c:5366

stack backtrace:
CPU: 1 PID: 10330 Comm: syz-executor.0 Not tainted 6.1.91-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/02/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2fa/0x3b0 kernel/locking/lockdep.c:2170
 check_prev_add kernel/locking/lockdep.c:3090 [inline]
 check_prevs_add kernel/locking/lockdep.c:3209 [inline]
 validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
 down_read+0xad/0xa30 kernel/locking/rwsem.c:1520
 filemap_invalidate_lock_shared include/linux/fs.h:813 [inline]
 filemap_fault+0x640/0x17e0 mm/filemap.c:3191
 __do_fault+0x136/0x4f0 mm/memory.c:4261
 do_read_fault mm/memory.c:4612 [inline]
 do_fault mm/memory.c:4741 [inline]
 handle_pte_fault mm/memory.c:5013 [inline]
 __handle_mm_fault mm/memory.c:5155 [inline]
 handle_mm_fault+0x3412/0x5340 mm/memory.c:5276
 do_user_addr_fault arch/x86/mm/fault.c:1371 [inline]
 handle_page_fault arch/x86/mm/fault.c:1462 [inline]
 exc_page_fault+0x26f/0x660 arch/x86/mm/fault.c:1518
 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570
RIP: 0010:copy_user_enhanced_fast_string+0xa/0x40 arch/x86/lib/copy_user_64.S:166
Code: ff c9 75 f2 89 d1 c1 e9 03 83 e2 07 f3 48 a5 89 d1 f3 a4 31 c0 0f 01 ca c3 8d 0c ca 89 ca eb 20 0f 01 cb 83 fa 40 72 38 89 d1 <f3> a4 31 c0 0f 01 ca c3 89 ca eb 0a 66 2e 0f 1f 84 00 00 00 00 00
RSP: 0018:ffffc9000395f470 EFLAGS: 00050206
RAX: ffffffff84363101 RBX: 00007ffffffef000 RCX: 0000000000008080
RDX: 0000000000010000 RSI: 0000000020008000 RDI: ffff888055f27fac
RBP: ffffc9000395f5f0 R08: dffffc0000000000 R09: ffffed100abe6006
R10: 0000000000000006 R11: dffffc0000000001 R12: 0000000000010000
R13: 0000000000000000 R14: ffff888055f2002c R15: 0000000020000080
 copy_user_generic arch/x86/include/asm/uaccess_64.h:37 [inline]
 raw_copy_from_user arch/x86/include/asm/uaccess_64.h:52 [inline]
 copyin+0xd8/0x120 lib/iov_iter.c:183
 _copy_from_iter+0x493/0xff0 lib/iov_iter.c:631
 copy_from_iter include/linux/uio.h:187 [inline]
 copy_from_iter_full include/linux/uio.h:194 [inline]
 memcpy_from_msg include/linux/skbuff.h:4004 [inline]
 virtio_transport_alloc_skb+0x4b0/0x1220 net/vmw_vsock/virtio_transport_common.c:76
 virtio_transport_send_pkt_info+0x2d4/0x6f0 net/vmw_vsock/virtio_transport_common.c:237
 virtio_transport_stream_enqueue+0x151/0x1f0 net/vmw_vsock/virtio_transport_common.c:821
 vsock_connectible_sendmsg+0xa01/0xde0 net/vmw_vsock/af_vsock.c:1864
 sock_sendmsg_nosec net/socket.c:718 [inline]
 __sock_sendmsg net/socket.c:730 [inline]
 sock_write_iter+0x394/0x4e0 net/socket.c:1143
 do_iter_write+0x6e6/0xc50 fs/read_write.c:861
 vfs_writev fs/read_write.c:934 [inline]
 do_writev+0x27b/0x460 fs/read_write.c:977
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f8b77a7cee9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 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 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f8b787cd0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000014
RAX: ffffffffffffffda RBX: 00007f8b77babf80 RCX: 00007f8b77a7cee9
RDX: 0000000000000002 RSI: 00000000200002c0 RDI: 0000000000000009
RBP: 00007f8b77ac949e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f8b77babf80 R15: 00007ffc0cf5f8d8
 </TASK>
----------------
Code disassembly (best guess):
   0:	ff c9                	dec    %ecx
   2:	75 f2                	jne    0xfffffff6
   4:	89 d1                	mov    %edx,%ecx
   6:	c1 e9 03             	shr    $0x3,%ecx
   9:	83 e2 07             	and    $0x7,%edx
   c:	f3 48 a5             	rep movsq %ds:(%rsi),%es:(%rdi)
   f:	89 d1                	mov    %edx,%ecx
  11:	f3 a4                	rep movsb %ds:(%rsi),%es:(%rdi)
  13:	31 c0                	xor    %eax,%eax
  15:	0f 01 ca             	clac
  18:	c3                   	ret
  19:	8d 0c ca             	lea    (%rdx,%rcx,8),%ecx
  1c:	89 ca                	mov    %ecx,%edx
  1e:	eb 20                	jmp    0x40
  20:	0f 01 cb             	stac
  23:	83 fa 40             	cmp    $0x40,%edx
  26:	72 38                	jb     0x60
  28:	89 d1                	mov    %edx,%ecx
* 2a:	f3 a4                	rep movsb %ds:(%rsi),%es:(%rdi) <-- trapping instruction
  2c:	31 c0                	xor    %eax,%eax
  2e:	0f 01 ca             	clac
  31:	c3                   	ret
  32:	89 ca                	mov    %ecx,%edx
  34:	eb 0a                	jmp    0x40
  36:	66 2e 0f 1f 84 00 00 	cs nopw 0x0(%rax,%rax,1)
  3d:	00 00 00

Crashes (32):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/05/18 05:22 linux-6.1.y 4078fa637fcd c0f1611a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in filemap_fault
2024/05/18 02:48 linux-6.1.y 4078fa637fcd c0f1611a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in filemap_fault
2024/05/16 20:31 linux-6.1.y 909ba1f1b414 c2e07261 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in filemap_fault
2024/05/15 14:25 linux-6.1.y 909ba1f1b414 94b087b1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in filemap_fault
2024/05/14 05:25 linux-6.1.y 909ba1f1b414 fdb4c10c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in filemap_fault
2024/05/04 06:13 linux-6.1.y 909ba1f1b414 610f2a54 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in filemap_fault
2024/04/26 15:51 linux-6.1.y 6741e066ec76 059e9963 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in filemap_fault
2024/04/25 18:33 linux-6.1.y 6741e066ec76 8bdc0f22 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in filemap_fault
2024/04/20 06:21 linux-6.1.y 6741e066ec76 af24b050 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in filemap_fault
2024/03/29 17:58 linux-6.1.y e5cd595e23c1 c52bcb23 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in filemap_fault
2024/01/04 04:02 linux-6.1.y a507f147e6f0 28c42cff .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in filemap_fault
2023/12/22 21:26 linux-6.1.y 4aa6747d9352 fb427a07 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in filemap_fault
2024/05/18 02:23 linux-6.1.y 4078fa637fcd c0f1611a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/05/18 02:23 linux-6.1.y 4078fa637fcd c0f1611a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/05/17 13:45 linux-6.1.y 4078fa637fcd a12e99e7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/05/17 13:45 linux-6.1.y 4078fa637fcd a12e99e7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/05/16 21:18 linux-6.1.y 909ba1f1b414 c2e07261 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/05/10 18:28 linux-6.1.y 909ba1f1b414 f7c35481 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/05/09 20:46 linux-6.1.y 909ba1f1b414 05079661 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/05/07 02:40 linux-6.1.y 909ba1f1b414 fa7a5cf0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/05/03 11:52 linux-6.1.y 909ba1f1b414 dd26401e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/05/02 18:15 linux-6.1.y 909ba1f1b414 3ba885bc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/05/02 16:15 linux-6.1.y 909ba1f1b414 3ba885bc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/05/01 14:31 linux-6.1.y dcbc050cb0d3 3ba885bc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/04/29 22:57 linux-6.1.y dcbc050cb0d3 f10afd69 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/04/24 19:52 linux-6.1.y 6741e066ec76 8bdc0f22 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/04/17 17:36 linux-6.1.y 6741e066ec76 acc528cb .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/04/14 03:21 linux-6.1.y cd5d98c0556c c8349e48 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/04/10 03:58 linux-6.1.y 347385861c50 171ec371 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/04/10 03:58 linux-6.1.y 347385861c50 171ec371 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/03/25 18:02 linux-6.1.y d7543167affd 0ea90952 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
2024/03/23 06:45 linux-6.1.y d7543167affd 0ea90952 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in filemap_fault
* Struck through repros no longer work on HEAD.