syzbot


possible deadlock in ntfs_fallocate

Status: upstream: reported on 2022/12/09 08:57
Subsystems: ntfs3
[Documentation on labels]
Reported-by: syzbot+adacb2b0c896bc427962@syzkaller.appspotmail.com
First crash: 444d, last: 17d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] possible deadlock in ntfs_fallocate 0 (1) 2022/12/09 08:57
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in ntfs_fallocate 2 24d 95d 0/3 upstream: reported on 2023/11/22 18:34

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.8.0-rc3-syzkaller-00047-g047371968ffc #0 Not tainted
------------------------------------------------------
syz-executor.2/14201 is trying to acquire lock:
ffff8880467d0fc0 (&ni->ni_lock/4){+.+.}-{3:3}, at: ni_lock fs/ntfs3/ntfs_fs.h:1124 [inline]
ffff8880467d0fc0 (&ni->ni_lock/4){+.+.}-{3:3}, at: ntfs_fallocate+0x787/0x1070 fs/ntfs3/file.c:548

but task is already holding lock:
ffff8880467d1400 (mapping.invalidate_lock#12){++++}-{3:3}, at: filemap_invalidate_lock include/linux/fs.h:847 [inline]
ffff8880467d1400 (mapping.invalidate_lock#12){++++}-{3:3}, at: ntfs_fallocate+0x3ac/0x1070 fs/ntfs3/file.c:484

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (mapping.invalidate_lock#12){++++}-{3:3}:
       lock_acquire+0x1e3/0x530 kernel/locking/lockdep.c:5754
       down_read+0xb1/0xa40 kernel/locking/rwsem.c:1526
       filemap_invalidate_lock_shared include/linux/fs.h:857 [inline]
       filemap_fault+0x646/0x1680 mm/filemap.c:3237
       __do_fault+0x135/0x460 mm/memory.c:4376
       do_read_fault mm/memory.c:4738 [inline]
       do_fault mm/memory.c:4868 [inline]
       do_pte_missing mm/memory.c:3745 [inline]
       handle_pte_fault mm/memory.c:5144 [inline]
       __handle_mm_fault+0x49e6/0x72d0 mm/memory.c:5285
       handle_mm_fault+0x27e/0x770 mm/memory.c:5450
       do_user_addr_fault arch/x86/mm/fault.c:1415 [inline]
       handle_page_fault arch/x86/mm/fault.c:1507 [inline]
       exc_page_fault+0x2ad/0x870 arch/x86/mm/fault.c:1563
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570
       strncpy_from_user+0x111/0x2f0 lib/strncpy_from_user.c:139
       getname_flags+0xf9/0x4f0 fs/namei.c:151
       getname fs/namei.c:219 [inline]
       __do_sys_mkdirat fs/namei.c:4160 [inline]
       __se_sys_mkdirat fs/namei.c:4158 [inline]
       __x64_sys_mkdirat+0x7c/0xa0 fs/namei.c:4158
       do_syscall_64+0xf9/0x240
       entry_SYSCALL_64_after_hwframe+0x6f/0x77

-> #2 (&mm->mmap_lock){++++}-{3:3}:
       lock_acquire+0x1e3/0x530 kernel/locking/lockdep.c:5754
       __might_fault+0xc5/0x120 mm/memory.c:6060
       _copy_to_user+0x2a/0xb0 lib/usercopy.c:36
       copy_to_user include/linux/uaccess.h:191 [inline]
       fiemap_fill_next_extent+0x235/0x410 fs/ioctl.c:145
       ni_fiemap+0xa5e/0x1230 fs/ntfs3/frecord.c:2065
       ntfs_fiemap+0x132/0x180 fs/ntfs3/file.c:1164
       ioctl_fiemap fs/ioctl.c:220 [inline]
       do_vfs_ioctl+0x1a02/0x2b60 fs/ioctl.c:811
       __do_sys_ioctl fs/ioctl.c:869 [inline]
       __se_sys_ioctl+0x81/0x170 fs/ioctl.c:857
       do_syscall_64+0xf9/0x240
       entry_SYSCALL_64_after_hwframe+0x6f/0x77

-> #1 (&indx->run_lock){++++}-{3:3}:
       lock_acquire+0x1e3/0x530 kernel/locking/lockdep.c:5754
       down_read+0xb1/0xa40 kernel/locking/rwsem.c:1526
       ni_fiemap+0x373/0x1230 fs/ntfs3/frecord.c:1961
       ntfs_fiemap+0x132/0x180 fs/ntfs3/file.c:1164
       ioctl_fiemap fs/ioctl.c:220 [inline]
       do_vfs_ioctl+0x1a02/0x2b60 fs/ioctl.c:811
       __do_sys_ioctl fs/ioctl.c:869 [inline]
       __se_sys_ioctl+0x81/0x170 fs/ioctl.c:857
       do_syscall_64+0xf9/0x240
       entry_SYSCALL_64_after_hwframe+0x6f/0x77

-> #0 (&ni->ni_lock/4){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3134 [inline]
       check_prevs_add kernel/locking/lockdep.c:3253 [inline]
       validate_chain+0x18ca/0x58e0 kernel/locking/lockdep.c:3869
       __lock_acquire+0x1345/0x1fd0 kernel/locking/lockdep.c:5137
       lock_acquire+0x1e3/0x530 kernel/locking/lockdep.c:5754
       __mutex_lock_common kernel/locking/mutex.c:608 [inline]
       __mutex_lock+0x136/0xd70 kernel/locking/mutex.c:752
       ni_lock fs/ntfs3/ntfs_fs.h:1124 [inline]
       ntfs_fallocate+0x787/0x1070 fs/ntfs3/file.c:548
       vfs_fallocate+0x564/0x6c0 fs/open.c:328
       ksys_fallocate fs/open.c:351 [inline]
       __do_sys_fallocate fs/open.c:359 [inline]
       __se_sys_fallocate fs/open.c:357 [inline]
       __x64_sys_fallocate+0xbd/0x110 fs/open.c:357
       do_syscall_64+0xf9/0x240
       entry_SYSCALL_64_after_hwframe+0x6f/0x77

other info that might help us debug this:

Chain exists of:
  &ni->ni_lock/4 --> &mm->mmap_lock --> mapping.invalidate_lock#12

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(mapping.invalidate_lock#12);
                               lock(&mm->mmap_lock);
                               lock(mapping.invalidate_lock#12);
  lock(&ni->ni_lock/4);

 *** DEADLOCK ***

3 locks held by syz-executor.2/14201:
 #0: ffff888031a56420 (sb_writers#24){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:2795 [inline]
 #0: ffff888031a56420 (sb_writers#24){.+.+}-{0:0}, at: vfs_fallocate+0x4d3/0x6c0 fs/open.c:327
 #1: ffff8880467d1260 (&sb->s_type->i_mutex_key#35){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:802 [inline]
 #1: ffff8880467d1260 (&sb->s_type->i_mutex_key#35){+.+.}-{3:3}, at: ntfs_fallocate+0x2dd/0x1070 fs/ntfs3/file.c:470
 #2: ffff8880467d1400 (mapping.invalidate_lock#12){++++}-{3:3}, at: filemap_invalidate_lock include/linux/fs.h:847 [inline]
 #2: ffff8880467d1400 (mapping.invalidate_lock#12){++++}-{3:3}, at: ntfs_fallocate+0x3ac/0x1070 fs/ntfs3/file.c:484

stack backtrace:
CPU: 1 PID: 14201 Comm: syz-executor.2 Not tainted 6.8.0-rc3-syzkaller-00047-g047371968ffc #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e7/0x2e0 lib/dump_stack.c:106
 check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2187
 check_prev_add kernel/locking/lockdep.c:3134 [inline]
 check_prevs_add kernel/locking/lockdep.c:3253 [inline]
 validate_chain+0x18ca/0x58e0 kernel/locking/lockdep.c:3869
 __lock_acquire+0x1345/0x1fd0 kernel/locking/lockdep.c:5137
 lock_acquire+0x1e3/0x530 kernel/locking/lockdep.c:5754
 __mutex_lock_common kernel/locking/mutex.c:608 [inline]
 __mutex_lock+0x136/0xd70 kernel/locking/mutex.c:752
 ni_lock fs/ntfs3/ntfs_fs.h:1124 [inline]
 ntfs_fallocate+0x787/0x1070 fs/ntfs3/file.c:548
 vfs_fallocate+0x564/0x6c0 fs/open.c:328
 ksys_fallocate fs/open.c:351 [inline]
 __do_sys_fallocate fs/open.c:359 [inline]
 __se_sys_fallocate fs/open.c:357 [inline]
 __x64_sys_fallocate+0xbd/0x110 fs/open.c:357
 do_syscall_64+0xf9/0x240
 entry_SYSCALL_64_after_hwframe+0x6f/0x77
RIP: 0033:0x7fb9df87dda9
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:00007fb9e05b60c8 EFLAGS: 00000246 ORIG_RAX: 000000000000011d
RAX: ffffffffffffffda RBX: 00007fb9df9abf80 RCX: 00007fb9df87dda9
RDX: 0000000000000000 RSI: 0000000000000008 RDI: 0000000000000004
RBP: 00007fb9df8ca47a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000008000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007fb9df9abf80 R15: 00007ffc9be9a308
 </TASK>

Crashes (28):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/02/08 15:49 upstream 047371968ffc 7f07e9b0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2024/01/28 08:51 upstream 8a696a29c690 cc4a4020 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2024/01/26 07:29 upstream ecb1b8288dc7 cc4a4020 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2023/12/30 01:37 upstream f016f7547aee fb427a07 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2023/12/18 11:36 upstream ceb6a6f023fd 3222d10c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2023/12/18 06:21 upstream 0e389834672c 3222d10c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2023/11/21 21:53 upstream c2d5304e6c64 cb976f63 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2023/11/07 22:08 upstream 13d88ac54ddd 83211397 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2023/10/27 14:30 upstream 750b95887e56 3c418d72 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2023/10/26 20:29 upstream 3a568e3a961b 23afc60f .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2023/08/19 08:33 upstream d4ddefee5160 d216d8a0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2023/07/07 17:41 upstream 5133c9e51de4 668cb1fa .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2023/04/15 07:12 upstream 95abc817ab3a ec410564 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2023/03/30 08:12 upstream ffe78bbd5121 f325deb0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2023/02/18 05:51 upstream 38f8ccde04a3 d02e9a70 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2022/12/16 14:12 upstream 84e57d292203 79e1d513 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in ntfs_fallocate
2022/12/16 08:36 upstream 851f657a8642 6f9c033e .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2022/12/14 12:42 upstream 02bf43c7b7f7 f6511626 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2022/12/09 03:02 upstream f3e8416619ce 1034e5fa .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in ntfs_fallocate
2024/01/18 13:29 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 0802e17d9aca 239abf84 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 possible deadlock in ntfs_fallocate
2024/01/18 08:41 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 0802e17d9aca 915053c7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 possible deadlock in ntfs_fallocate
2023/07/24 23:41 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci e40939bbfc68 9a0ddda3 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 possible deadlock in ntfs_fallocate
2023/05/13 05:42 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 14f8db1c0f9a 2b9ba477 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 possible deadlock in ntfs_fallocate
2023/04/18 18:16 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 327bf9bb94cf d931e9f0 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 possible deadlock in ntfs_fallocate
2023/04/15 00:34 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 1f5b16c51aef ec410564 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 possible deadlock in ntfs_fallocate
2023/04/01 15:47 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 59caa87f9dfb f325deb0 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 possible deadlock in ntfs_fallocate
2023/03/23 21:12 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci fe15c26ee26e f94b4a29 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 possible deadlock in ntfs_fallocate
2023/02/14 13:43 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 2d3827b3f393 1d6b4af7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 possible deadlock in ntfs_fallocate
* Struck through repros no longer work on HEAD.