[v5.15] possible deadlock in ntfs_file_mmap

0 views
Skip to first unread message

syzbot

unread,
Aug 19, 2024, 9:49:21 AM8/19/24
Hello,

syzbot found the following issue on:

HEAD commit: fa93fa65db6e Linux 5.15.165
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=10a7efd3980000
kernel config: https://syzkaller.appspot.com/x/.config?x=d027d7ba4e9e9586
dashboard link: https://syzkaller.appspot.com/bug?extid=a01597ecdc366fb3475b
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/7401830de8b7/disk-fa93fa65.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/55f1128c249c/vmlinux-fa93fa65.xz
kernel image: https://storage.googleapis.com/syzbot-assets/5ce80d349162/bzImage-fa93fa65.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

ntfs3: loop1: Different NTFS' sector size (4096) and media sector size (512)
ntfs3: loop1: Mark volume as dirty due to NTFS errors
======================================================
WARNING: possible circular locking dependency detected
5.15.165-syzkaller #0 Not tainted
------------------------------------------------------
syz.1.1404/8112 is trying to acquire lock:
ffff8880613feae0 (&sb->s_type->i_mutex_key#25){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:789 [inline]
ffff8880613feae0 (&sb->s_type->i_mutex_key#25){+.+.}-{3:3}, at: ntfs_file_mmap+0x589/0x7e0 fs/ntfs3/file.c:401

but task is already holding lock:
ffff88807ca96328 (&mm->mmap_lock){++++}-{3:3}, at: mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline]
ffff88807ca96328 (&mm->mmap_lock){++++}-{3:3}, at: vm_mmap_pgoff+0x175/0x2d0 mm/util.c:549

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&mm->mmap_lock){++++}-{3:3}:
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
internal_get_user_pages_fast+0x212/0x2810 mm/gup.c:2895
iov_iter_get_pages+0x25a/0x570 lib/iov_iter.c:1544
dio_refill_pages fs/direct-io.c:173 [inline]
dio_get_page fs/direct-io.c:217 [inline]
do_direct_IO fs/direct-io.c:938 [inline]
do_blockdev_direct_IO fs/direct-io.c:1276 [inline]
__blockdev_direct_IO+0x1419/0x4f40 fs/direct-io.c:1368
blockdev_direct_IO include/linux/fs.h:3303 [inline]
ntfs_direct_IO+0x193/0x360 fs/ntfs3/inode.c:798
generic_file_read_iter+0x28d/0x460 mm/filemap.c:2772
call_read_iter include/linux/fs.h:2166 [inline]
new_sync_read fs/read_write.c:404 [inline]
vfs_read+0xa93/0xe10 fs/read_write.c:485
ksys_read+0x1a2/0x2c0 fs/read_write.c:623
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #0 (&sb->s_type->i_mutex_key#25){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain+0x1649/0x5930 kernel/locking/lockdep.c:3788
__lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
down_write+0x38/0x60 kernel/locking/rwsem.c:1551
inode_lock include/linux/fs.h:789 [inline]
ntfs_file_mmap+0x589/0x7e0 fs/ntfs3/file.c:401
call_mmap include/linux/fs.h:2177 [inline]
mmap_region+0x10e7/0x1670 mm/mmap.c:1791
do_mmap+0x78d/0xe00 mm/mmap.c:1575
vm_mmap_pgoff+0x1ca/0x2d0 mm/util.c:551
ksys_mmap_pgoff+0x559/0x780 mm/mmap.c:1624
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&mm->mmap_lock);
lock(&sb->s_type->i_mutex_key#25);
lock(&mm->mmap_lock);
lock(&sb->s_type->i_mutex_key#25);

*** DEADLOCK ***

1 lock held by syz.1.1404/8112:
#0: ffff88807ca96328 (&mm->mmap_lock){++++}-{3:3}, at: mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline]
#0: ffff88807ca96328 (&mm->mmap_lock){++++}-{3:3}, at: vm_mmap_pgoff+0x175/0x2d0 mm/util.c:549

stack backtrace:
CPU: 1 PID: 8112 Comm: syz.1.1404 Not tainted 5.15.165-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
check_noncircular+0x2f8/0x3b0 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+0x1649/0x5930 kernel/locking/lockdep.c:3788
__lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
down_write+0x38/0x60 kernel/locking/rwsem.c:1551
inode_lock include/linux/fs.h:789 [inline]
ntfs_file_mmap+0x589/0x7e0 fs/ntfs3/file.c:401
call_mmap include/linux/fs.h:2177 [inline]
mmap_region+0x10e7/0x1670 mm/mmap.c:1791
do_mmap+0x78d/0xe00 mm/mmap.c:1575
vm_mmap_pgoff+0x1ca/0x2d0 mm/util.c:551
ksys_mmap_pgoff+0x559/0x780 mm/mmap.c:1624
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f6af9760e79
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:00007f6af7bdd038 EFLAGS: 00000246 ORIG_RAX: 0000000000000009
RAX: ffffffffffffffda RBX: 00007f6af98fcf80 RCX: 00007f6af9760e79
RDX: 0000000000000002 RSI: 0000000000013000 RDI: 0000000020525000
RBP: 00007f6af97ce916 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000000028011 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f6af98fcf80 R15: 00007ffed01e2c68
</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 [email protected].

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,
Aug 19, 2024, 10:14:29 PM8/19/24
syzbot has found a reproducer for the following issue on:

HEAD commit: fa93fa65db6e Linux 5.15.165
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=16cf93cb980000
kernel config: https://syzkaller.appspot.com/x/.config?x=e925c06d1329f45e
dashboard link: https://syzkaller.appspot.com/bug?extid=a01597ecdc366fb3475b
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=11095cfd980000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=123c0bf5980000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/24db9409dadf/disk-fa93fa65.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/1a49888d62d1/vmlinux-fa93fa65.xz
kernel image: https://storage.googleapis.com/syzbot-assets/519fcf35a482/Image-fa93fa65.gz.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/f9f24b6265b2/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

ntfs3: loop0: Different NTFS' sector size (4096) and media sector size (512)
ntfs3: loop0: Mark volume as dirty due to NTFS errors
======================================================
WARNING: possible circular locking dependency detected
5.15.165-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor103/4016 is trying to acquire lock:
ffff0000dd787240 (&sb->s_type->i_mutex_key#17){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:789 [inline]
ffff0000dd787240 (&sb->s_type->i_mutex_key#17){+.+.}-{3:3}, at: ntfs_file_mmap+0x4b0/0x688 fs/ntfs3/file.c:401

but task is already holding lock:
ffff0000ca119818 (&mm->mmap_lock){++++}-{3:3}, at: mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline]
ffff0000ca119818 (&mm->mmap_lock){++++}-{3:3}, at: vm_mmap_pgoff+0x15c/0x2b4 mm/util.c:549

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&mm->mmap_lock){++++}-{3:3}:
__might_fault+0xc8/0x128 mm/memory.c:5328
fault_in_readable+0xdc/0x56c mm/gup.c:1793
fault_in_iov_iter_readable+0x130/0x1b0 lib/iov_iter.c:460
generic_perform_write+0x198/0x520 mm/filemap.c:3775
__generic_file_write_iter+0x230/0x454 mm/filemap.c:3912
ntfs_file_write_iter+0x40c/0x49c fs/ntfs3/file.c:1143
call_write_iter include/linux/fs.h:2172 [inline]
new_sync_write fs/read_write.c:507 [inline]
vfs_write+0x884/0xb44 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:608
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #0 (&sb->s_type->i_mutex_key#17){+.+.}-{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:3788 [inline]
__lock_acquire+0x32d4/0x7638 kernel/locking/lockdep.c:5012
lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5623
down_write+0xbc/0x12c kernel/locking/rwsem.c:1551
inode_lock include/linux/fs.h:789 [inline]
ntfs_file_mmap+0x4b0/0x688 fs/ntfs3/file.c:401
call_mmap include/linux/fs.h:2177 [inline]
mmap_region+0xcb4/0x12f0 mm/mmap.c:1791
do_mmap+0x6c0/0xcec mm/mmap.c:1575
vm_mmap_pgoff+0x1a4/0x2b4 mm/util.c:551
ksys_mmap_pgoff+0x458/0x668 mm/mmap.c:1624
__do_sys_mmap arch/arm64/kernel/sys.c:28 [inline]
__se_sys_mmap arch/arm64/kernel/sys.c:21 [inline]
__arm64_sys_mmap+0xf8/0x110 arch/arm64/kernel/sys.c:21
__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:608
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
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(&mm->mmap_lock);
lock(&sb->s_type->i_mutex_key#17);
lock(&mm->mmap_lock);
lock(&sb->s_type->i_mutex_key#17);

*** DEADLOCK ***

1 lock held by syz-executor103/4016:
#0: ffff0000ca119818 (&mm->mmap_lock){++++}-{3:3}, at: mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline]
#0: ffff0000ca119818 (&mm->mmap_lock){++++}-{3:3}, at: vm_mmap_pgoff+0x15c/0x2b4 mm/util.c:549

stack backtrace:
CPU: 0 PID: 4016 Comm: syz-executor103 Not tainted 5.15.165-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
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:3788 [inline]
__lock_acquire+0x32d4/0x7638 kernel/locking/lockdep.c:5012
lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5623
down_write+0xbc/0x12c kernel/locking/rwsem.c:1551
inode_lock include/linux/fs.h:789 [inline]
ntfs_file_mmap+0x4b0/0x688 fs/ntfs3/file.c:401
call_mmap include/linux/fs.h:2177 [inline]
mmap_region+0xcb4/0x12f0 mm/mmap.c:1791
do_mmap+0x6c0/0xcec mm/mmap.c:1575
vm_mmap_pgoff+0x1a4/0x2b4 mm/util.c:551
ksys_mmap_pgoff+0x458/0x668 mm/mmap.c:1624
__do_sys_mmap arch/arm64/kernel/sys.c:28 [inline]
__se_sys_mmap arch/arm64/kernel/sys.c:21 [inline]
__arm64_sys_mmap+0xf8/0x110 arch/arm64/kernel/sys.c:21
__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:608
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584


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