syzbot


possible deadlock in ni_fiemap

Status: upstream: reported C repro on 2022/10/18 05:47
Reported-by: syzbot+c300ab283ba3bc072439@syzkaller.appspotmail.com
First crash: 46d, last: 1d08h

Sample crash report:
loop0: detected capacity change from 0 to 4096
======================================================
WARNING: possible circular locking dependency detected
6.1.0-rc7-syzkaller-00101-g01f856ae6d0c #0 Not tainted
------------------------------------------------------
syz-executor911/3632 is trying to acquire lock:
ffff888021991718 (&mm->mmap_lock#2){++++}-{3:3}, at: __might_fault+0x8f/0x110 mm/memory.c:5645

but task is already holding lock:
ffff8880741101b0 (&ni->file.run_lock#3){++++}-{3:3}, at: ni_fiemap+0x32b/0x1130 fs/ntfs3/frecord.c:1947

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ni->file.run_lock#3){++++}-{3:3}:
       lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
       down_read+0x39/0x50 kernel/locking/rwsem.c:1509
       attr_data_get_block+0x158/0x2370 fs/ntfs3/attrib.c:899
       ntfs_file_mmap+0x48c/0x730 fs/ntfs3/file.c:387
       call_mmap include/linux/fs.h:2204 [inline]
       mmap_region+0xfe6/0x1e20 mm/mmap.c:2625
       do_mmap+0x8d9/0xf30 mm/mmap.c:1412
       vm_mmap_pgoff+0x19e/0x2b0 mm/util.c:520
       ksys_mmap_pgoff+0x48c/0x6d0 mm/mmap.c:1458
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 (&mm->mmap_lock#2){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3097 [inline]
       check_prevs_add kernel/locking/lockdep.c:3216 [inline]
       validate_chain+0x1898/0x6ae0 kernel/locking/lockdep.c:3831
       __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055
       lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
       __might_fault+0xb2/0x110 mm/memory.c:5646
       _copy_to_user+0x26/0x130 lib/usercopy.c:29
       copy_to_user include/linux/uaccess.h:169 [inline]
       fiemap_fill_next_extent+0x22e/0x410 fs/ioctl.c:144
       ni_fiemap+0xa11/0x1130 fs/ntfs3/frecord.c:2051
       ntfs_fiemap+0x134/0x180 fs/ntfs3/file.c:1245
       ioctl_fiemap fs/ioctl.c:219 [inline]
       do_vfs_ioctl+0x187f/0x29a0 fs/ioctl.c:810
       __do_sys_ioctl fs/ioctl.c:868 [inline]
       __se_sys_ioctl+0x83/0x170 fs/ioctl.c:856
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

other info that might help us debug this:

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

2 locks held by syz-executor911/3632:
 #0: ffff888074110100 (&ni->ni_lock/4){+.+.}-{3:3}, at: ni_lock fs/ntfs3/ntfs_fs.h:1108 [inline]
 #0: ffff888074110100 (&ni->ni_lock/4){+.+.}-{3:3}, at: ntfs_fiemap+0x101/0x180 fs/ntfs3/file.c:1243
 #1: ffff8880741101b0 (&ni->file.run_lock#3){++++}-{3:3}, at: ni_fiemap+0x32b/0x1130 fs/ntfs3/frecord.c:1947

stack backtrace:
CPU: 0 PID: 3632 Comm: syz-executor911 Not tainted 6.1.0-rc7-syzkaller-00101-g01f856ae6d0c #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106
 check_noncircular+0x2cc/0x390 kernel/locking/lockdep.c:2177
 check_prev_add kernel/locking/lockdep.c:3097 [inline]
 check_prevs_add kernel/locking/lockdep.c:3216 [inline]
 validate_chain+0x1898/0x6ae0 kernel/locking/lockdep.c:3831
 __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055
 lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
 __might_fault+0xb2/0x110 mm/memory.c:5646
 _copy_to_user+0x26/0x130 lib/usercopy.c:29
 copy_to_user include/linux/uaccess.h:169 [inline]
 fiemap_fill_next_extent+0x22e/0x410 fs/ioctl.c:144
 ni_fiemap+0xa11/0x1130 fs/ntfs3/frecord.c:2051
 ntfs_fiemap+0x134/0x180 fs/ntfs3/file.c:1245
 ioctl_fiemap fs/ioctl.c:219 [inline]
 do_vfs_ioctl+0x187f/0x29a0 fs/ioctl.c:810
 __do_sys_ioctl fs/ioctl.c:868 [inline]
 __se_sys_ioctl+0x83/0x170 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7febc4d60d69
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 14 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fffe05c24d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007febc4d60d69
RDX: 00000000200001c0 RSI: 00000000c020660b RDI: 00000000

Crashes (19):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-upstream-fs 2022/11/30 17:25 upstream 01f856ae6d0c 4c2a66e8 .config log report syz C possible deadlock in ni_fiemap
ci2-upstream-fs 2022/12/02 07:42 upstream ef4d3ea40565 e080de16 .config log report info possible deadlock in ni_fiemap
ci2-upstream-fs 2022/12/02 00:56 upstream ef4d3ea40565 e080de16 .config log report info possible deadlock in ni_fiemap
ci2-upstream-fs 2022/12/01 23:23 upstream ef4d3ea40565 e080de16 .config log report info possible deadlock in ni_fiemap
ci2-upstream-fs 2022/12/01 18:22 upstream ef4d3ea40565 e080de16 .config log report info possible deadlock in ni_fiemap
ci2-upstream-fs 2022/12/01 10:53 upstream 04aa64375f48 4c2a66e8 .config log report info possible deadlock in ni_fiemap
ci-upstream-kasan-gce-root 2022/12/01 10:07 upstream ef4d3ea40565 4c2a66e8 .config log report info possible deadlock in ni_fiemap
ci2-upstream-fs 2022/11/30 17:09 upstream 01f856ae6d0c 4c2a66e8 .config log report info possible deadlock in ni_fiemap
ci2-upstream-fs 2022/11/30 12:26 upstream 01f856ae6d0c 4c2a66e8 .config log report info possible deadlock in ni_fiemap
ci2-upstream-fs 2022/11/30 05:58 upstream 01f856ae6d0c 579a3740 .config log report info possible deadlock in ni_fiemap
ci2-upstream-fs 2022/11/29 17:06 upstream ca57f02295f1 579a3740 .config log report info possible deadlock in ni_fiemap
ci2-upstream-fs 2022/11/29 07:18 upstream ca57f02295f1 ca9683b8 .config log report info possible deadlock in ni_fiemap
ci2-upstream-fs 2022/11/29 00:33 upstream b7b275e60bcd ca9683b8 .config log report info possible deadlock in ni_fiemap
ci2-upstream-fs 2022/11/28 12:58 upstream b7b275e60bcd 247de55b .config log report info possible deadlock in ni_fiemap
ci2-upstream-fs 2022/11/18 14:09 upstream 84368d882b96 5bb70014 .config log report info possible deadlock in ni_fiemap
ci-upstream-gce-arm64 2022/11/14 12:16 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 1621b6eaebf7 943f4cb8 .config log report info possible deadlock in ni_fiemap
ci-upstream-gce-arm64 2022/11/12 20:19 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 1621b6eaebf7 3ead01ad .config log report info possible deadlock in ni_fiemap
ci-upstream-gce-arm64 2022/11/01 18:45 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci bbed346d5a96 edac4fd1 .config log report info possible deadlock in ni_fiemap
ci-upstream-gce-arm64 2022/10/18 00:14 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci bbed346d5a96 754863b4 .config log report info possible deadlock in ni_fiemap
* Struck through repros no longer work on HEAD.