[syzbot] [ntfs3?] possible deadlock in mark_as_free_ex (2)

10 views
Skip to first unread message

syzbot

unread,
Nov 8, 2024, 2:38:25 AM11/8/24
to almaz.ale...@paragon-software.com, linux-...@vger.kernel.org, nt...@lists.linux.dev, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 74741a050b79 Add linux-next specific files for 20241107
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=11f6035f980000
kernel config: https://syzkaller.appspot.com/x/.config?x=d3ef0574c9dc8b00
dashboard link: https://syzkaller.appspot.com/bug?extid=8df514c431bd240c5644
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/8993ea1d09da/disk-74741a05.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/dab7bc3c6e88/vmlinux-74741a05.xz
kernel image: https://storage.googleapis.com/syzbot-assets/fda543ad532f/bzImage-74741a05.xz

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

loop3: detected capacity change from 0 to 4096
======================================================
WARNING: possible circular locking dependency detected
6.12.0-rc6-next-20241107-syzkaller #0 Not tainted
------------------------------------------------------
syz.3.1671/10772 is trying to acquire lock:
ffff88803034a270 (&wnd->rw_lock){++++}-{4:4}, at: mark_as_free_ex+0x3e/0x390 fs/ntfs3/fsntfs.c:2484

but task is already holding lock:
ffff888069fc0908 (&ni->file.run_lock#2){++++}-{4:4}, at: ntfs_truncate fs/ntfs3/file.c:505 [inline]
ffff888069fc0908 (&ni->file.run_lock#2){++++}-{4:4}, at: ntfs_setattr+0x6d3/0xb80 fs/ntfs3/file.c:824

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ni->file.run_lock#2){++++}-{4:4}:
lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
down_read+0xb1/0xa40 kernel/locking/rwsem.c:1524
run_unpack_ex+0x55e/0x9e0 fs/ntfs3/run.c:1119
ntfs_read_mft fs/ntfs3/inode.c:401 [inline]
ntfs_iget5+0x1f9a/0x37b0 fs/ntfs3/inode.c:537
ntfs_dir_emit fs/ntfs3/dir.c:335 [inline]
ntfs_read_hdr+0x700/0xb80 fs/ntfs3/dir.c:383
ntfs_readdir+0x91f/0xf00 fs/ntfs3/dir.c:494
iterate_dir+0x571/0x800 fs/readdir.c:108
__do_sys_getdents fs/readdir.c:322 [inline]
__se_sys_getdents+0x1fd/0x4e0 fs/readdir.c:308
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&wnd->rw_lock){++++}-{4:4}:
check_prev_add kernel/locking/lockdep.c:3161 [inline]
check_prevs_add kernel/locking/lockdep.c:3280 [inline]
validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904
__lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226
lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
down_write_nested+0xa2/0x220 kernel/locking/rwsem.c:1693
mark_as_free_ex+0x3e/0x390 fs/ntfs3/fsntfs.c:2484
run_deallocate_ex+0x244/0x5f0 fs/ntfs3/attrib.c:122
attr_set_size+0x168d/0x4300 fs/ntfs3/attrib.c:753
ntfs_truncate fs/ntfs3/file.c:506 [inline]
ntfs_setattr+0x7a4/0xb80 fs/ntfs3/file.c:824
notify_change+0xbca/0xe90 fs/attr.c:552
do_truncate+0x220/0x310 fs/open.c:65
handle_truncate fs/namei.c:3449 [inline]
do_open fs/namei.c:3832 [inline]
path_openat+0x2e1e/0x3590 fs/namei.c:3987
do_filp_open+0x27f/0x4e0 fs/namei.c:4014
do_sys_openat2+0x13e/0x1d0 fs/open.c:1402
do_sys_open fs/open.c:1417 [inline]
__do_sys_creat fs/open.c:1495 [inline]
__se_sys_creat fs/open.c:1489 [inline]
__x64_sys_creat+0x123/0x170 fs/open.c:1489
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&ni->file.run_lock#2);
lock(&wnd->rw_lock);
lock(&ni->file.run_lock#2);
lock(&wnd->rw_lock);

*** DEADLOCK ***

4 locks held by syz.3.1671/10772:
#0: ffff88803034c420 (sb_writers#22){.+.+}-{0:0}, at: mnt_want_write+0x3f/0x90 fs/namespace.c:515
#1: ffff888069fc0af0 (&sb->s_type->i_mutex_key#35){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:817 [inline]
#1: ffff888069fc0af0 (&sb->s_type->i_mutex_key#35){+.+.}-{4:4}, at: do_truncate+0x20c/0x310 fs/open.c:63
#2: ffff888069fc0858 (&ni->ni_lock#2/5){+.+.}-{4:4}, at: ni_lock fs/ntfs3/ntfs_fs.h:1110 [inline]
#2: ffff888069fc0858 (&ni->ni_lock#2/5){+.+.}-{4:4}, at: ntfs_truncate fs/ntfs3/file.c:503 [inline]
#2: ffff888069fc0858 (&ni->ni_lock#2/5){+.+.}-{4:4}, at: ntfs_setattr+0x6bf/0xb80 fs/ntfs3/file.c:824
#3: ffff888069fc0908 (&ni->file.run_lock#2){++++}-{4:4}, at: ntfs_truncate fs/ntfs3/file.c:505 [inline]
#3: ffff888069fc0908 (&ni->file.run_lock#2){++++}-{4:4}, at: ntfs_setattr+0x6d3/0xb80 fs/ntfs3/file.c:824

stack backtrace:
CPU: 0 UID: 0 PID: 10772 Comm: syz.3.1671 Not tainted 6.12.0-rc6-next-20241107-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/30/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
print_circular_bug+0x13a/0x1b0 kernel/locking/lockdep.c:2074
check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2206
check_prev_add kernel/locking/lockdep.c:3161 [inline]
check_prevs_add kernel/locking/lockdep.c:3280 [inline]
validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904
__lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226
lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
down_write_nested+0xa2/0x220 kernel/locking/rwsem.c:1693
mark_as_free_ex+0x3e/0x390 fs/ntfs3/fsntfs.c:2484
run_deallocate_ex+0x244/0x5f0 fs/ntfs3/attrib.c:122
attr_set_size+0x168d/0x4300 fs/ntfs3/attrib.c:753
ntfs_truncate fs/ntfs3/file.c:506 [inline]
ntfs_setattr+0x7a4/0xb80 fs/ntfs3/file.c:824
notify_change+0xbca/0xe90 fs/attr.c:552
do_truncate+0x220/0x310 fs/open.c:65
handle_truncate fs/namei.c:3449 [inline]
do_open fs/namei.c:3832 [inline]
path_openat+0x2e1e/0x3590 fs/namei.c:3987
do_filp_open+0x27f/0x4e0 fs/namei.c:4014
do_sys_openat2+0x13e/0x1d0 fs/open.c:1402
do_sys_open fs/open.c:1417 [inline]
__do_sys_creat fs/open.c:1495 [inline]
__se_sys_creat fs/open.c:1489 [inline]
__x64_sys_creat+0x123/0x170 fs/open.c:1489
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fca7137e719
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:00007fca720ea038 EFLAGS: 00000246 ORIG_RAX: 0000000000000055
RAX: ffffffffffffffda RBX: 00007fca71535f80 RCX: 00007fca7137e719
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020002440
RBP: 00007fca713f139e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fca71535f80 R15: 00007fffe9ba7408
</TASK>


---
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 report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

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

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

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

syzbot

unread,
Nov 28, 2024, 8:43:26 PM11/28/24
to almaz.ale...@paragon-software.com, linux-...@vger.kernel.org, nt...@lists.linux.dev, syzkall...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 7af08b57bcb9 Merge tag 'trace-v6.13-2' of git://git.kernel..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1607cf78580000
kernel config: https://syzkaller.appspot.com/x/.config?x=129a9798def93175
dashboard link: https://syzkaller.appspot.com/bug?extid=8df514c431bd240c5644
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=136b33c0580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/f6e67f04bc76/disk-7af08b57.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/31932bddea1f/vmlinux-7af08b57.xz
kernel image: https://storage.googleapis.com/syzbot-assets/62707034e0dd/bzImage-7af08b57.xz
mounted in repro #1: https://storage.googleapis.com/syzbot-assets/8dd5f7e91d9f/mount_0.gz
mounted in repro #2: https://storage.googleapis.com/syzbot-assets/732aad914e95/mount_3.gz

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

loop2: detected capacity change from 0 to 4096
======================================================
WARNING: possible circular locking dependency detected
6.12.0-syzkaller-10689-g7af08b57bcb9 #0 Not tainted
------------------------------------------------------
syz.2.134/6316 is trying to acquire lock:
ffff88807b844270 (&wnd->rw_lock){++++}-{4:4}, at: mark_as_free_ex+0x3e/0x390 fs/ntfs3/fsntfs.c:2484

but task is already holding lock:
ffff88805ac3adc0 (&ni->file.run_lock#2){++++}-{4:4}, at: ntfs_truncate fs/ntfs3/file.c:505 [inline]
ffff88805ac3adc0 (&ni->file.run_lock#2){++++}-{4:4}, at: ntfs_setattr+0x6d3/0xb80 fs/ntfs3/file.c:824

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ni->file.run_lock#2){++++}-{4:4}:
lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
down_read+0xb1/0xa40 kernel/locking/rwsem.c:1524
run_unpack_ex+0x55e/0x9e0 fs/ntfs3/run.c:1119
ntfs_read_mft fs/ntfs3/inode.c:401 [inline]
ntfs_iget5+0x1f9a/0x37b0 fs/ntfs3/inode.c:537
dir_search_u+0x2fe/0x3a0 fs/ntfs3/dir.c:264
ntfs_lookup+0x106/0x1f0 fs/ntfs3/namei.c:85
lookup_one_qstr_excl+0x11f/0x260 fs/namei.c:1692
do_renameat2+0x670/0x13f0 fs/namei.c:5165
__do_sys_rename fs/namei.c:5271 [inline]
__se_sys_rename fs/namei.c:5269 [inline]
__x64_sys_rename+0x82/0x90 fs/namei.c:5269
4 locks held by syz.2.134/6316:
#0: ffff88807b842420 (sb_writers#13){.+.+}-{0:0}, at: mnt_want_write+0x3f/0x90 fs/namespace.c:515
#1: ffff88805ac3afa8 (&sb->s_type->i_mutex_key#22){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:818 [inline]
#1: ffff88805ac3afa8 (&sb->s_type->i_mutex_key#22){+.+.}-{4:4}, at: do_truncate+0x20c/0x310 fs/open.c:63
#2: ffff88805ac3ad10 (&ni->ni_lock#3/5){+.+.}-{4:4}, at: ni_lock fs/ntfs3/ntfs_fs.h:1110 [inline]
#2: ffff88805ac3ad10 (&ni->ni_lock#3/5){+.+.}-{4:4}, at: ntfs_truncate fs/ntfs3/file.c:503 [inline]
#2: ffff88805ac3ad10 (&ni->ni_lock#3/5){+.+.}-{4:4}, at: ntfs_setattr+0x6bf/0xb80 fs/ntfs3/file.c:824
#3: ffff88805ac3adc0 (&ni->file.run_lock#2){++++}-{4:4}, at: ntfs_truncate fs/ntfs3/file.c:505 [inline]
#3: ffff88805ac3adc0 (&ni->file.run_lock#2){++++}-{4:4}, at: ntfs_setattr+0x6d3/0xb80 fs/ntfs3/file.c:824

stack backtrace:
CPU: 1 UID: 0 PID: 6316 Comm: syz.2.134 Not tainted 6.12.0-syzkaller-10689-g7af08b57bcb9 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
RIP: 0033:0x7fb9f1980809
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:00007fb9f282a058 EFLAGS: 00000246 ORIG_RAX: 0000000000000055
RAX: ffffffffffffffda RBX: 00007fb9f1b45fa0 RCX: 00007fb9f1980809
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000200002c0
RBP: 00007fb9f19f393e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fb9f1b45fa0 R15: 00007ffcedbec7c8
</TASK>


---
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.

syzbot

unread,
Dec 12, 2024, 3:35:30 AM12/12/24
to almaz.ale...@paragon-software.com, linux-...@vger.kernel.org, nt...@lists.linux.dev, syzkall...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 231825b2e1ff Revert "unicode: Don't special case ignorable..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1635ebe8580000
kernel config: https://syzkaller.appspot.com/x/.config?x=c7c9f223bfe8924e
dashboard link: https://syzkaller.appspot.com/bug?extid=8df514c431bd240c5644
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=128e6cdf980000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1784b20f980000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/dc23b60ff29a/disk-231825b2.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/377c8f65d53a/vmlinux-231825b2.xz
kernel image: https://storage.googleapis.com/syzbot-assets/09bc1abb7c7a/bzImage-231825b2.xz
mounted in repro #1: https://storage.googleapis.com/syzbot-assets/fe1662038b98/mount_0.gz
mounted in repro #2: https://storage.googleapis.com/syzbot-assets/5c6aa5da5c24/mount_3.gz

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

ntfs3(loop3): Mark volume as dirty due to NTFS errors
======================================================
WARNING: possible circular locking dependency detected
6.13.0-rc2-syzkaller-00036-g231825b2e1ff #0 Not tainted
------------------------------------------------------
syz-executor149/6544 is trying to acquire lock:
ffff88807e17a270 (&wnd->rw_lock){++++}-{4:4}, at: mark_as_free_ex+0x3e/0x390 fs/ntfs3/fsntfs.c:2484

but task is already holding lock:
ffff8880705e43c8 (&ni->file.run_lock#2){++++}-{4:4}, at: ntfs_truncate fs/ntfs3/file.c:505 [inline]
ffff8880705e43c8 (&ni->file.run_lock#2){++++}-{4:4}, at: ntfs_setattr+0x6d3/0xb80 fs/ntfs3/file.c:824

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ni->file.run_lock#2){++++}-{4:4}:
lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
down_read+0xb1/0xa40 kernel/locking/rwsem.c:1524
run_unpack_ex+0x55e/0x9e0 fs/ntfs3/run.c:1119
ntfs_read_mft fs/ntfs3/inode.c:401 [inline]
ntfs_iget5+0x1f9a/0x37b0 fs/ntfs3/inode.c:537
ntfs_dir_emit fs/ntfs3/dir.c:335 [inline]
ntfs_read_hdr+0x700/0xb80 fs/ntfs3/dir.c:383
ntfs_readdir+0x91f/0xf00 fs/ntfs3/dir.c:494
iterate_dir+0x571/0x800 fs/readdir.c:108
__do_sys_getdents64 fs/readdir.c:403 [inline]
__se_sys_getdents64+0x1e2/0x4b0 fs/readdir.c:389
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&wnd->rw_lock){++++}-{4:4}:
check_prev_add kernel/locking/lockdep.c:3161 [inline]
check_prevs_add kernel/locking/lockdep.c:3280 [inline]
validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904
__lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226
lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
down_write_nested+0xa2/0x220 kernel/locking/rwsem.c:1693
mark_as_free_ex+0x3e/0x390 fs/ntfs3/fsntfs.c:2484
run_deallocate_ex+0x244/0x5f0 fs/ntfs3/attrib.c:122
attr_set_size+0x168d/0x4300 fs/ntfs3/attrib.c:753
ntfs_truncate fs/ntfs3/file.c:506 [inline]
ntfs_setattr+0x7a4/0xb80 fs/ntfs3/file.c:824
notify_change+0xbca/0xe90 fs/attr.c:552
do_truncate+0x220/0x310 fs/open.c:65
handle_truncate fs/namei.c:3449 [inline]
do_open fs/namei.c:3832 [inline]
path_openat+0x2e1e/0x3590 fs/namei.c:3987
do_filp_open+0x27f/0x4e0 fs/namei.c:4014
do_sys_openat2+0x13e/0x1d0 fs/open.c:1402
do_sys_open fs/open.c:1417 [inline]
__do_sys_open fs/open.c:1425 [inline]
__se_sys_open fs/open.c:1421 [inline]
__x64_sys_open+0x225/0x270 fs/open.c:1421
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&ni->file.run_lock#2);
lock(&wnd->rw_lock);
lock(&ni->file.run_lock#2);
lock(&wnd->rw_lock);

*** DEADLOCK ***

4 locks held by syz-executor149/6544:
#0: ffff888079980420 (sb_writers#11){.+.+}-{0:0}, at: mnt_want_write+0x3f/0x90 fs/namespace.c:515
#1: ffff8880705e45b0 (&sb->s_type->i_mutex_key#19){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:818 [inline]
#1: ffff8880705e45b0 (&sb->s_type->i_mutex_key#19){+.+.}-{4:4}, at: do_truncate+0x20c/0x310 fs/open.c:63
#2: ffff8880705e4318 (&ni->ni_lock#2/5){+.+.}-{4:4}, at: ni_lock fs/ntfs3/ntfs_fs.h:1110 [inline]
#2: ffff8880705e4318 (&ni->ni_lock#2/5){+.+.}-{4:4}, at: ntfs_truncate fs/ntfs3/file.c:503 [inline]
#2: ffff8880705e4318 (&ni->ni_lock#2/5){+.+.}-{4:4}, at: ntfs_setattr+0x6bf/0xb80 fs/ntfs3/file.c:824
#3: ffff8880705e43c8 (&ni->file.run_lock#2){++++}-{4:4}, at: ntfs_truncate fs/ntfs3/file.c:505 [inline]
#3: ffff8880705e43c8 (&ni->file.run_lock#2){++++}-{4:4}, at: ntfs_setattr+0x6d3/0xb80 fs/ntfs3/file.c:824

stack backtrace:
CPU: 1 UID: 0 PID: 6544 Comm: syz-executor149 Not tainted 6.13.0-rc2-syzkaller-00036-g231825b2e1ff #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/25/2024
__do_sys_open fs/open.c:1425 [inline]
__se_sys_open fs/open.c:1421 [inline]
__x64_sys_open+0x225/0x270 fs/open.c:1421
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f17dc4ac879
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 1c 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffc503e84b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f17dc4ac879
RDX: 00000000000001d8 RSI: 0000000000147383 RDI: 0000000020000240
RBP: 00007ffc503e84ec R08: 000000000001f216 R09: 0000000020000880
R10: 00007ffc503e8380 R11: 0000000000000246 R12: 00007ffc503e8540
R13: 00007ffc503e8500 R14: 0000000000024ec5 R15: 0000000000000090

syzbot

unread,
Dec 13, 2024, 1:43:03 AM12/13/24
to almaz.ale...@paragon-software.com, linux-...@vger.kernel.org, nt...@lists.linux.dev, syzkall...@googlegroups.com
syzbot has bisected this issue to:

commit 5fc982fe7eca9d0cf7b25832450ebd4f7c8e1c36
Author: Konstantin Komarov <almaz.ale...@paragon-software.com>
Date: Thu Oct 10 17:09:24 2024 +0000

fs/ntfs3: Fix case when unmarked clusters intersect with zone

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=15a78730580000
start commit: 231825b2e1ff Revert "unicode: Don't special case ignorable..
git tree: upstream
final oops: https://syzkaller.appspot.com/x/report.txt?x=17a78730580000
console output: https://syzkaller.appspot.com/x/log.txt?x=13a78730580000
Reported-by: syzbot+8df514...@syzkaller.appspotmail.com
Fixes: 5fc982fe7eca ("fs/ntfs3: Fix case when unmarked clusters intersect with zone")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

Lizhi Xu

unread,
Dec 13, 2024, 3:24:08 AM12/13/24
to syzbot+8df514...@syzkaller.appspotmail.com, syzkall...@googlegroups.com
reset the lock order for openat

#syz test

diff --git a/fs/ntfs3/run.c b/fs/ntfs3/run.c
index 6e86d6619..38ebd65f0 100644
--- a/fs/ntfs3/run.c
+++ b/fs/ntfs3/run.c
@@ -1096,9 +1096,17 @@ int run_unpack_ex(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,

/* Looks like volume is corrupted. */
ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
-
- if (!down_write_trylock(&wnd->rw_lock))
+ struct rw_semaphore *lock =
+ is_mounted(sbi) ? &sbi->mft.ni->file.run_lock :
+ NULL;
+ if (zone && lock)
+ down_read(lock);
+
+ if (!down_write_trylock(&wnd->rw_lock)) {
+ if (zone && lock)
+ up_read(lock);
continue;
+ }

if (zone) {
/*
@@ -1112,16 +1120,11 @@ int run_unpack_ex(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
err = wnd_set_used_safe(wnd, lcn, len, &done);
if (zone) {
/* Restore zone. Lock mft run. */
- struct rw_semaphore *lock =
- is_mounted(sbi) ? &sbi->mft.ni->file.run_lock :
- NULL;
- if (lock)
- down_read(lock);
ntfs_refresh_zone(sbi);
- if (lock)
- up_read(lock);
}
up_write(&wnd->rw_lock);
+ if (zone && lock)
+ up_read(lock);
if (err)
return err;
}

syzbot

unread,
Dec 13, 2024, 4:02:05 AM12/13/24
to linux-...@vger.kernel.org, lizh...@windriver.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+8df514...@syzkaller.appspotmail.com
Tested-by: syzbot+8df514...@syzkaller.appspotmail.com

Tested on:

commit: f932fb9b Merge tag 'v6.13-rc2-ksmbd-server-fixes' of g..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=174dc4f8580000
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=156f6a0f980000

Note: testing is done by a robot and is best-effort only.

Lizhi Xu

unread,
Dec 13, 2024, 4:05:06 AM12/13/24
to syzbot+8df514...@syzkaller.appspotmail.com, almaz.ale...@paragon-software.com, linux-...@vger.kernel.org, nt...@lists.linux.dev, syzkall...@googlegroups.com
syzbot reported a deadlock in mark_as_free_ex. [1]

Reset the order of mft and used locks to avoid this issue.

[1]
Fixes: 5fc982fe7eca ("fs/ntfs3: Fix case when unmarked clusters intersect with zone")
Reported-by: syzbot+8df514...@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=8df514c431bd240c5644
Tested-by: syzbot+8df514...@syzkaller.appspotmail.com
Signed-off-by: Lizhi Xu <lizh...@windriver.com>
---
fs/ntfs3/run.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/fs/ntfs3/run.c b/fs/ntfs3/run.c
index 6e86d66197ef..fdac1f941379 100644
--- a/fs/ntfs3/run.c
+++ b/fs/ntfs3/run.c
@@ -1096,9 +1096,17 @@ int run_unpack_ex(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,

/* Looks like volume is corrupted. */
ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
-
- if (!down_write_trylock(&wnd->rw_lock))
+ struct rw_semaphore *lock =
+ is_mounted(sbi) ? &sbi->mft.ni->file.run_lock :
+ NULL;
+ if (zone && lock)
+ down_read(lock);
+
+ if (!down_write_trylock(&wnd->rw_lock)) {
+ if (zone && lock)
+ up_read(lock);
continue;
+ }

if (zone) {
/*
@@ -1112,16 +1120,12 @@ int run_unpack_ex(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
err = wnd_set_used_safe(wnd, lcn, len, &done);
if (zone) {
/* Restore zone. Lock mft run. */
- struct rw_semaphore *lock =
- is_mounted(sbi) ? &sbi->mft.ni->file.run_lock :
- NULL;
- if (lock)
- down_read(lock);
ntfs_refresh_zone(sbi);
- if (lock)
- up_read(lock);
}
up_write(&wnd->rw_lock);
+ if (zone && lock)
+ up_read(lock);
+
if (err)
return err;
}
--
2.43.0

syzbot

unread,
Jan 17, 2026, 7:45:04 AM (21 hours ago) Jan 17
to almaz.ale...@paragon-software.com, linux-...@vger.kernel.org, lizh...@windriver.com, nt...@lists.linux.dev, syzkall...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit bcbb8d0afd94927215e8ae97c40cfefa807cfe0b
Author: Konstantin Komarov <almaz.ale...@paragon-software.com>
Date: Thu Oct 30 20:51:09 2025 +0000

fs/ntfs3: change the default mount options for "acl" and "prealloc"

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=12e7739a580000
start commit: c9cfc122f037 Merge tag 'for-6.18-rc4-tag' of git://git.ker..
git tree: upstream
kernel config: https://syzkaller.appspot.com/x/.config?x=41ad820f608cb833
dashboard link: https://syzkaller.appspot.com/bug?extid=8df514c431bd240c5644
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=114e4a58580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10bfc084580000

If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: fs/ntfs3: change the default mount options for "acl" and "prealloc"
Reply all
Reply to author
Forward
0 new messages