[v6.1] possible deadlock in ntfs_fallocate

0 views
Skip to first unread message

syzbot

unread,
Nov 26, 2023, 10:37:01 AM11/26/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 69e434a1cb21 Linux 6.1.63
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1701aad0e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=8936a912d77a129d
dashboard link: https://syzkaller.appspot.com/bug?extid=e5a561d1c6c138fdb32a
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/8f4c34d49102/disk-69e434a1.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/415c50ae270f/vmlinux-69e434a1.xz
kernel image: https://storage.googleapis.com/syzbot-assets/71f602f135dc/Image-69e434a1.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+e5a561...@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
6.1.63-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.1/11777 is trying to acquire lock:
ffff0001233e1720 (&ni->ni_lock/4){+.+.}-{3:3}, at: ni_lock fs/ntfs3/ntfs_fs.h:1111 [inline]
ffff0001233e1720 (&ni->ni_lock/4){+.+.}-{3:3}, at: ntfs_fallocate+0x604/0xd88 fs/ntfs3/file.c:650

but task is already holding lock:
ffff0001233e1b60 (mapping.invalidate_lock#7){++++}-{3:3}, at: filemap_invalidate_lock include/linux/fs.h:801 [inline]
ffff0001233e1b60 (mapping.invalidate_lock#7){++++}-{3:3}, at: ntfs_fallocate+0x2fc/0xd88 fs/ntfs3/file.c:583

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (mapping.invalidate_lock#7){++++}-{3:3}:
down_read+0x64/0x308 kernel/locking/rwsem.c:1520
filemap_invalidate_lock_shared include/linux/fs.h:811 [inline]
page_cache_ra_unbounded+0xc8/0x58c mm/readahead.c:226
do_page_cache_ra mm/readahead.c:300 [inline]
page_cache_ra_order+0x7fc/0x994 mm/readahead.c:560
do_sync_mmap_readahead+0x3a4/0x844
filemap_fault+0x604/0xf7c mm/filemap.c:3190
__do_fault+0x11c/0x3d8 mm/memory.c:4241
do_shared_fault mm/memory.c:4647 [inline]
do_fault mm/memory.c:4725 [inline]
handle_pte_fault mm/memory.c:4993 [inline]
__handle_mm_fault mm/memory.c:5135 [inline]
handle_mm_fault+0x18e4/0x3e9c mm/memory.c:5256
faultin_page mm/gup.c:1009 [inline]
__get_user_pages+0x3b0/0x968 mm/gup.c:1233
__get_user_pages_locked mm/gup.c:1437 [inline]
__gup_longterm_locked+0x210/0xf6c mm/gup.c:2132
pin_user_pages+0x8c/0xc4 mm/gup.c:3282
xdp_umem_pin_pages net/xdp/xdp_umem.c:105 [inline]
xdp_umem_reg net/xdp/xdp_umem.c:218 [inline]
xdp_umem_create+0x7bc/0xd6c net/xdp/xdp_umem.c:251
xsk_setsockopt+0x74c/0x9e4 net/xdp/xsk.c:1113
__sys_setsockopt+0x3a8/0x70c net/socket.c:2269
__do_sys_setsockopt net/socket.c:2280 [inline]
__se_sys_setsockopt net/socket.c:2277 [inline]
__arm64_sys_setsockopt+0xb8/0xd4 net/socket.c:2277
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

-> #2 (&mm->mmap_lock){++++}-{3:3}:
__might_fault+0xc4/0x124 mm/memory.c:5811
_copy_to_user include/linux/uaccess.h:143 [inline]
copy_to_user include/linux/uaccess.h:169 [inline]
fiemap_fill_next_extent+0x1b4/0x424 fs/ioctl.c:144
ni_fiemap+0x744/0xe10 fs/ntfs3/frecord.c:2045
ntfs_fiemap+0x110/0x168 fs/ntfs3/file.c:1245
ioctl_fiemap fs/ioctl.c:219 [inline]
do_vfs_ioctl+0x194c/0x26f8 fs/ioctl.c:810
__do_sys_ioctl fs/ioctl.c:868 [inline]
__se_sys_ioctl fs/ioctl.c:856 [inline]
__arm64_sys_ioctl+0xe4/0x1c8 fs/ioctl.c:856
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

-> #1 (&ni->file.run_lock){.+.+}-{3:3}:
down_read+0x64/0x308 kernel/locking/rwsem.c:1520
ni_fiemap+0x2c4/0xe10 fs/ntfs3/frecord.c:1962
ntfs_fiemap+0x110/0x168 fs/ntfs3/file.c:1245
ioctl_fiemap fs/ioctl.c:219 [inline]
do_vfs_ioctl+0x194c/0x26f8 fs/ioctl.c:810
__do_sys_ioctl fs/ioctl.c:868 [inline]
__se_sys_ioctl fs/ioctl.c:856 [inline]
__arm64_sys_ioctl+0xe4/0x1c8 fs/ioctl.c:856
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

-> #0 (&ni->ni_lock/4){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3090 [inline]
check_prevs_add kernel/locking/lockdep.c:3209 [inline]
validate_chain kernel/locking/lockdep.c:3824 [inline]
__lock_acquire+0x3338/0x764c kernel/locking/lockdep.c:5048
lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5661
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
ni_lock fs/ntfs3/ntfs_fs.h:1111 [inline]
ntfs_fallocate+0x604/0xd88 fs/ntfs3/file.c:650
vfs_fallocate+0x478/0x5b4 fs/open.c:323
ksys_fallocate fs/open.c:346 [inline]
__do_sys_fallocate fs/open.c:354 [inline]
__se_sys_fallocate fs/open.c:352 [inline]
__arm64_sys_fallocate+0xc0/0x110 fs/open.c:352
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

other info that might help us debug this:

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

Possible unsafe locking scenario:

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

*** DEADLOCK ***

3 locks held by syz-executor.1/11777:
#0: ffff0000da664460 (sb_writers#26){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:2950 [inline]
#0: ffff0000da664460 (sb_writers#26){.+.+}-{0:0}, at: vfs_fallocate+0x404/0x5b4 fs/open.c:322
#1: ffff0001233e19c0 (&sb->s_type->i_mutex_key#33){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
#1: ffff0001233e19c0 (&sb->s_type->i_mutex_key#33){+.+.}-{3:3}, at: ntfs_fallocate+0x25c/0xd88 fs/ntfs3/file.c:569
#2: ffff0001233e1b60 (mapping.invalidate_lock#7){++++}-{3:3}, at: filemap_invalidate_lock include/linux/fs.h:801 [inline]
#2: ffff0001233e1b60 (mapping.invalidate_lock#7){++++}-{3:3}, at: ntfs_fallocate+0x2fc/0xd88 fs/ntfs3/file.c:583

stack backtrace:
CPU: 0 PID: 11777 Comm: syz-executor.1 Not tainted 6.1.63-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023
Call trace:
dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
__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:2048
check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2170
check_prev_add kernel/locking/lockdep.c:3090 [inline]
check_prevs_add kernel/locking/lockdep.c:3209 [inline]
validate_chain kernel/locking/lockdep.c:3824 [inline]
__lock_acquire+0x3338/0x764c kernel/locking/lockdep.c:5048
lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5661
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
ni_lock fs/ntfs3/ntfs_fs.h:1111 [inline]
ntfs_fallocate+0x604/0xd88 fs/ntfs3/file.c:650
vfs_fallocate+0x478/0x5b4 fs/open.c:323
ksys_fallocate fs/open.c:346 [inline]
__do_sys_fallocate fs/open.c:354 [inline]
__se_sys_fallocate fs/open.c:352 [inline]
__arm64_sys_fallocate+0xc0/0x110 fs/open.c:352
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585


---
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
Reply all
Reply to author
Forward
0 new messages