[v5.15] possible deadlock in ntfs_set_state

1 view
Skip to first unread message

syzbot

unread,
Sep 11, 2023, 10:25:15 PM9/11/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: aff03380bda4 Linux 5.15.131
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1091e70c680000
kernel config: https://syzkaller.appspot.com/x/.config?x=deb2c375928f6168
dashboard link: https://syzkaller.appspot.com/bug?extid=bbfc7e799e7ae709f809
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/a1b31fbb7be5/disk-aff03380.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/13a2ea527c11/vmlinux-aff03380.xz
kernel image: https://storage.googleapis.com/syzbot-assets/fc6620249c65/Image-aff03380.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+bbfc7e...@syzkaller.appspotmail.com

loop1: detected capacity change from 0 to 4096
ntfs3: loop1: Different NTFS' sector size (4096) and media sector size (512)
======================================================
WARNING: possible circular locking dependency detected
5.15.131-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.1/9978 is trying to acquire lock:
ffff0000d8d28860 (&ni->ni_lock){+.+.}-{3:3}, at: ntfs_set_state+0x1a4/0x5c4 fs/ntfs3/fsntfs.c:925

but task is already holding lock:
ffff0000d8d2e840 (&ni->ni_lock/4){+.+.}-{3:3}, at: ni_lock fs/ntfs3/ntfs_fs.h:1110 [inline]
ffff0000d8d2e840 (&ni->ni_lock/4){+.+.}-{3:3}, at: ntfs_lookup+0xf8/0x1f8 fs/ntfs3/namei.c:82

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ni->ni_lock/4){+.+.}-{3:3}:
__mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
ni_lock fs/ntfs3/ntfs_fs.h:1110 [inline]
mi_read+0x26c/0x4d8 fs/ntfs3/record.c:148
ntfs_read_mft fs/ntfs3/inode.c:69 [inline]
ntfs_iget5+0x358/0x2bcc fs/ntfs3/inode.c:524
ni_update_parent+0x688/0xa58 fs/ntfs3/frecord.c:3148
ni_write_inode+0x8a0/0xe38 fs/ntfs3/frecord.c:3246
ntfs3_write_inode+0x70/0x98 fs/ntfs3/inode.c:1036
write_inode fs/fs-writeback.c:1478 [inline]
__writeback_single_inode+0x584/0x13a4 fs/fs-writeback.c:1683
writeback_single_inode+0x1c0/0x79c fs/fs-writeback.c:1738
write_inode_now+0x240/0x2d0 fs/fs-writeback.c:2778
ntfs_extend+0x310/0x408 fs/ntfs3/file.c:458
ntfs_file_write_iter+0x2a0/0x49c fs/ntfs3/file.c:1139
call_write_iter include/linux/fs.h:2103 [inline]
new_sync_write fs/read_write.c:507 [inline]
vfs_write+0x87c/0xb3c fs/read_write.c:594
ksys_write+0x15c/0x26c fs/read_write.c:647
__do_sys_write fs/read_write.c:659 [inline]
__se_sys_write fs/read_write.c:656 [inline]
__arm64_sys_write+0x7c/0x90 fs/read_write.c:656
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #0 (&ni->ni_lock){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain kernel/locking/lockdep.c:3787 [inline]
__lock_acquire+0x32cc/0x7620 kernel/locking/lockdep.c:5011
lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5622
__mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
ntfs_set_state+0x1a4/0x5c4 fs/ntfs3/fsntfs.c:925
ntfs_iget5+0x710/0x2bcc fs/ntfs3/inode.c:531
dir_search_u+0x298/0x324 fs/ntfs3/dir.c:264
ntfs_lookup+0x108/0x1f8 fs/ntfs3/namei.c:83
lookup_open fs/namei.c:3370 [inline]
open_last_lookups fs/namei.c:3462 [inline]
path_openat+0xc9c/0x26f0 fs/namei.c:3669
do_filp_open+0x1a8/0x3b4 fs/namei.c:3699
do_sys_openat2+0x128/0x3d8 fs/open.c:1211
do_sys_open fs/open.c:1227 [inline]
__do_sys_openat fs/open.c:1243 [inline]
__se_sys_openat fs/open.c:1238 [inline]
__arm64_sys_openat+0x1f0/0x240 fs/open.c:1238
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&ni->ni_lock/4);
lock(&ni->ni_lock);
lock(&ni->ni_lock/4);
lock(&ni->ni_lock);

*** DEADLOCK ***

2 locks held by syz-executor.1/9978:
#0: ffff0000d8d2eae0 (&type->i_mutex_dir_key#8){++++}-{3:3}, at: inode_lock_shared include/linux/fs.h:797 [inline]
#0: ffff0000d8d2eae0 (&type->i_mutex_dir_key#8){++++}-{3:3}, at: open_last_lookups fs/namei.c:3461 [inline]
#0: ffff0000d8d2eae0 (&type->i_mutex_dir_key#8){++++}-{3:3}, at: path_openat+0x62c/0x26f0 fs/namei.c:3669
#1: ffff0000d8d2e840 (&ni->ni_lock/4){+.+.}-{3:3}, at: ni_lock fs/ntfs3/ntfs_fs.h:1110 [inline]
#1: ffff0000d8d2e840 (&ni->ni_lock/4){+.+.}-{3:3}, at: ntfs_lookup+0xf8/0x1f8 fs/ntfs3/namei.c:82

stack backtrace:
CPU: 1 PID: 9978 Comm: syz-executor.1 Not tainted 5.15.131-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
Call trace:
dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
dump_stack+0x1c/0x58 lib/dump_stack.c:113
print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2011
check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2133
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain kernel/locking/lockdep.c:3787 [inline]
__lock_acquire+0x32cc/0x7620 kernel/locking/lockdep.c:5011
lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5622
__mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
ntfs_set_state+0x1a4/0x5c4 fs/ntfs3/fsntfs.c:925
ntfs_iget5+0x710/0x2bcc fs/ntfs3/inode.c:531
dir_search_u+0x298/0x324 fs/ntfs3/dir.c:264
ntfs_lookup+0x108/0x1f8 fs/ntfs3/namei.c:83
lookup_open fs/namei.c:3370 [inline]
open_last_lookups fs/namei.c:3462 [inline]
path_openat+0xc9c/0x26f0 fs/namei.c:3669
do_filp_open+0x1a8/0x3b4 fs/namei.c:3699
do_sys_openat2+0x128/0x3d8 fs/open.c:1211
do_sys_open fs/open.c:1227 [inline]
__do_sys_openat fs/open.c:1243 [inline]
__se_sys_openat fs/open.c:1238 [inline]
__arm64_sys_openat+0x1f0/0x240 fs/open.c:1238
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584
ntfs3: loop1: Mark volume as dirty due to NTFS errors


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Sep 14, 2023, 5:51:09 AM9/14/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: aff03380bda4 Linux 5.15.131
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=10507c64680000
kernel config: https://syzkaller.appspot.com/x/.config?x=deb2c375928f6168
dashboard link: https://syzkaller.appspot.com/bug?extid=bbfc7e799e7ae709f809
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16069ea0680000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17c20152680000
mounted in repro: https://storage.googleapis.com/syzbot-assets/95197efd39fa/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+bbfc7e...@syzkaller.appspotmail.com

======================================================
WARNING: possible circular locking dependency detected
5.15.131-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor162/6651 is trying to acquire lock:
ffff0000dc1ce840 (&ni->ni_lock){+.+.}-{3:3}, at: ntfs_set_state+0x1a4/0x5c4 fs/ntfs3/fsntfs.c:925

but task is already holding lock:
ffff0000deba5980 (&ni->ni_lock/4){+.+.}-{3:3}, at: ni_lock fs/ntfs3/ntfs_fs.h:1110 [inline]
ffff0000deba5980 (&ni->ni_lock/4){+.+.}-{3:3}, at: ntfs_lookup+0xf8/0x1f8 fs/ntfs3/namei.c:82

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ni->ni_lock/4){+.+.}-{3:3}:
__mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
ni_lock fs/ntfs3/ntfs_fs.h:1110 [inline]
mi_read+0x26c/0x4d8 fs/ntfs3/record.c:148
ntfs_read_mft fs/ntfs3/inode.c:69 [inline]
ntfs_iget5+0x358/0x2bcc fs/ntfs3/inode.c:524
ni_update_parent+0x688/0xa58 fs/ntfs3/frecord.c:3148
ni_write_inode+0x8a0/0xe38 fs/ntfs3/frecord.c:3246
ntfs_sync_inode+0x2c/0x3c fs/ntfs3/inode.c:1041
ntfs_truncate fs/ntfs3/file.c:510 [inline]
ntfs3_setattr+0x784/0x974 fs/ntfs3/file.c:771
notify_change+0xac4/0xd60 fs/attr.c:489
do_truncate+0x1c0/0x28c fs/open.c:65
do_sys_ftruncate+0x288/0x31c fs/open.c:193
__do_sys_ftruncate fs/open.c:204 [inline]
__se_sys_ftruncate fs/open.c:202 [inline]
__arm64_sys_ftruncate+0x60/0x74 fs/open.c:202
3 locks held by syz-executor162/6651:
#0: ffff0000d1046460 (sb_writers#8){.+.+}-{0:0}, at: mnt_want_write+0x44/0x9c fs/namespace.c:377
#1: ffff0000deba5c20 (&type->i_mutex_dir_key#6){++++}-{3:3}, at: inode_lock include/linux/fs.h:787 [inline]
#1: ffff0000deba5c20 (&type->i_mutex_dir_key#6){++++}-{3:3}, at: open_last_lookups fs/namei.c:3459 [inline]
#1: ffff0000deba5c20 (&type->i_mutex_dir_key#6){++++}-{3:3}, at: path_openat+0x63c/0x26f0 fs/namei.c:3669
#2: ffff0000deba5980 (&ni->ni_lock/4){+.+.}-{3:3}, at: ni_lock fs/ntfs3/ntfs_fs.h:1110 [inline]
#2: ffff0000deba5980 (&ni->ni_lock/4){+.+.}-{3:3}, at: ntfs_lookup+0xf8/0x1f8 fs/ntfs3/namei.c:82

stack backtrace:
CPU: 1 PID: 6651 Comm: syz-executor162 Not tainted 5.15.131-syzkaller #0
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
Reply all
Reply to author
Forward
0 new messages