syzbot


possible deadlock in __ntfs_clear_inode

Status: auto-obsoleted due to no activity on 2024/07/08 00:19
Reported-by: syzbot+9b6965ca78b701ea3338@syzkaller.appspotmail.com
First crash: 236d, last: 236d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 possible deadlock in __ntfs_clear_inode ntfs 2 692d 711d 0/1 upstream: reported on 2022/12/10 22:52
upstream possible deadlock in __ntfs_clear_inode fs 345 297d 727d 0/28 auto-obsoleted due to no activity on 2024/04/08 06:19

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
5.15.153-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.4/9154 is trying to acquire lock:
ffff88806fafe400 (&rl->lock){+.+.}-{3:3}, at: __ntfs_clear_inode+0x32/0x1f0 fs/ntfs/inode.c:2189

but task is already holding lock:
ffffffff8c9e04a0 (fs_reclaim){+.+.}-{0:0}, at: __perform_reclaim mm/page_alloc.c:4621 [inline]
ffffffff8c9e04a0 (fs_reclaim){+.+.}-{0:0}, at: __alloc_pages_direct_reclaim mm/page_alloc.c:4645 [inline]
ffffffff8c9e04a0 (fs_reclaim){+.+.}-{0:0}, at: __alloc_pages_slowpath+0xfec/0x2800 mm/page_alloc.c:5051

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (fs_reclaim){+.+.}-{0:0}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       __fs_reclaim_acquire mm/page_alloc.c:4547 [inline]
       fs_reclaim_acquire+0x83/0x120 mm/page_alloc.c:4561
       prepare_alloc_pages+0x147/0x5b0 mm/page_alloc.c:5193
       __alloc_pages+0x14f/0x700 mm/page_alloc.c:5410
       __page_cache_alloc+0xd4/0x4a0 mm/filemap.c:1022
       do_read_cache_page+0x1e5/0x1040 mm/filemap.c:3457
       read_mapping_page include/linux/pagemap.h:515 [inline]
       ntfs_map_page+0x25/0x390 fs/ntfs/aops.h:75
       map_mft_record_page fs/ntfs/mft.c:73 [inline]
       map_mft_record+0x1ec/0x850 fs/ntfs/mft.c:156
       ntfs_read_locked_inode+0x199/0x49c0 fs/ntfs/inode.c:550
       ntfs_iget+0x10f/0x190 fs/ntfs/inode.c:177
       ntfs_lookup+0x28a/0xdf0 fs/ntfs/namei.c:117
       __lookup_slow+0x275/0x3d0 fs/namei.c:1663
       lookup_slow+0x53/0x70 fs/namei.c:1680
       walk_component+0x48c/0x610 fs/namei.c:1976
       lookup_last fs/namei.c:2431 [inline]
       path_lookupat+0x16f/0x450 fs/namei.c:2455
       filename_lookup+0x230/0x5c0 fs/namei.c:2484
       user_path_at_empty+0x40/0x180 fs/namei.c:2883
       user_path_at include/linux/namei.h:57 [inline]
       do_sys_truncate+0xa3/0x190 fs/open.c:132
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x61/0xcb

-> #1 (&ni->mrec_lock){+.+.}-{3:3}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       __mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
       map_mft_record+0x4a/0x850 fs/ntfs/mft.c:154
       ntfs_truncate+0x263/0x2860 fs/ntfs/inode.c:2383
       ntfs_truncate_vfs fs/ntfs/inode.c:2862 [inline]
       ntfs_setattr+0x2c7/0x3a0 fs/ntfs/inode.c:2914
       notify_change+0xc6d/0xf50 fs/attr.c:505
       do_truncate+0x21c/0x300 fs/open.c:65
       vfs_truncate+0x2dd/0x3a0 fs/open.c:111
       do_sys_truncate+0xda/0x190 fs/open.c:134
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x61/0xcb

-> #0 (&rl->lock){+.+.}-{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+0x97/0x170 kernel/locking/rwsem.c:1541
       __ntfs_clear_inode+0x32/0x1f0 fs/ntfs/inode.c:2189
       ntfs_evict_big_inode+0x2ad/0x480 fs/ntfs/inode.c:2278
       evict+0x2a4/0x620 fs/inode.c:587
       dispose_list fs/inode.c:620 [inline]
       prune_icache_sb+0x235/0x2e0 fs/inode.c:815
       super_cache_scan+0x372/0x480 fs/super.c:107
       do_shrink_slab+0x542/0xda0 mm/vmscan.c:758
       shrink_slab_memcg mm/vmscan.c:827 [inline]
       shrink_slab+0x5a1/0x960 mm/vmscan.c:906
       shrink_node_memcgs mm/vmscan.c:2951 [inline]
       shrink_node+0x1113/0x25d0 mm/vmscan.c:3072
       shrink_zones mm/vmscan.c:3275 [inline]
       do_try_to_free_pages+0x650/0x1670 mm/vmscan.c:3330
       try_to_free_pages+0x9dc/0xfd0 mm/vmscan.c:3565
       __perform_reclaim mm/page_alloc.c:4624 [inline]
       __alloc_pages_direct_reclaim mm/page_alloc.c:4645 [inline]
       __alloc_pages_slowpath+0x108a/0x2800 mm/page_alloc.c:5051
       __alloc_pages+0x45a/0x700 mm/page_alloc.c:5434
       vm_area_alloc_pages mm/vmalloc.c:2868 [inline]
       __vmalloc_area_node mm/vmalloc.c:2924 [inline]
       __vmalloc_node_range+0x5ab/0x8c0 mm/vmalloc.c:3029
       vmalloc_user+0x70/0x80 mm/vmalloc.c:3165
       vb2_vmalloc_alloc+0xee/0x330 drivers/media/common/videobuf2/videobuf2-vmalloc.c:47
       __vb2_buf_mem_alloc drivers/media/common/videobuf2/videobuf2-core.c:233 [inline]
       __vb2_queue_alloc+0x6f4/0x12d0 drivers/media/common/videobuf2/videobuf2-core.c:439
       vb2_core_create_bufs+0x496/0xaa0 drivers/media/common/videobuf2/videobuf2-core.c:946
       vb2_create_bufs+0x7d1/0x1080 drivers/media/common/videobuf2/videobuf2-v4l2.c:799
       v4l_create_bufs+0x1e2/0x340 drivers/media/v4l2-core/v4l2-ioctl.c:2072
       __video_do_ioctl+0xa44/0xe40 drivers/media/v4l2-core/v4l2-ioctl.c:2976
       video_usercopy+0xa87/0x1120 drivers/media/v4l2-core/v4l2-ioctl.c:3324
       v4l2_ioctl+0x181/0x1d0 drivers/media/v4l2-core/v4l2-dev.c:364
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:874 [inline]
       __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x61/0xcb

other info that might help us debug this:

Chain exists of:
  &rl->lock --> &ni->mrec_lock --> fs_reclaim

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(fs_reclaim);
                               lock(&ni->mrec_lock);
                               lock(fs_reclaim);
  lock(&rl->lock);

 *** DEADLOCK ***

4 locks held by syz-executor.4/9154:
 #0: ffff88805c5342f0 (&ctx->vb_mutex){+.+.}-{3:3}, at: __video_do_ioctl+0x505/0xe40 drivers/media/v4l2-core/v4l2-ioctl.c:2944
 #1: ffffffff8c9e04a0 (fs_reclaim){+.+.}-{0:0}, at: __perform_reclaim mm/page_alloc.c:4621 [inline]
 #1: ffffffff8c9e04a0 (fs_reclaim){+.+.}-{0:0}, at: __alloc_pages_direct_reclaim mm/page_alloc.c:4645 [inline]
 #1: ffffffff8c9e04a0 (fs_reclaim){+.+.}-{0:0}, at: __alloc_pages_slowpath+0xfec/0x2800 mm/page_alloc.c:5051
 #2: ffffffff8c9bdaf0 (shrinker_rwsem){++++}-{3:3}, at: shrink_slab_memcg mm/vmscan.c:800 [inline]
 #2: ffffffff8c9bdaf0 (shrinker_rwsem){++++}-{3:3}, at: shrink_slab+0x2d1/0x960 mm/vmscan.c:906
 #3: ffff88807a1160e0 (&type->s_umount_key#94){++++}-{3:3}, at: trylock_super fs/super.c:418 [inline]
 #3: ffff88807a1160e0 (&type->s_umount_key#94){++++}-{3:3}, at: super_cache_scan+0x73/0x480 fs/super.c:80

stack backtrace:
CPU: 0 PID: 9154 Comm: syz-executor.4 Not tainted 5.15.153-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb 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+0x97/0x170 kernel/locking/rwsem.c:1541
 __ntfs_clear_inode+0x32/0x1f0 fs/ntfs/inode.c:2189
 ntfs_evict_big_inode+0x2ad/0x480 fs/ntfs/inode.c:2278
 evict+0x2a4/0x620 fs/inode.c:587
 dispose_list fs/inode.c:620 [inline]
 prune_icache_sb+0x235/0x2e0 fs/inode.c:815
 super_cache_scan+0x372/0x480 fs/super.c:107
 do_shrink_slab+0x542/0xda0 mm/vmscan.c:758
 shrink_slab_memcg mm/vmscan.c:827 [inline]
 shrink_slab+0x5a1/0x960 mm/vmscan.c:906
 shrink_node_memcgs mm/vmscan.c:2951 [inline]
 shrink_node+0x1113/0x25d0 mm/vmscan.c:3072
 shrink_zones mm/vmscan.c:3275 [inline]
 do_try_to_free_pages+0x650/0x1670 mm/vmscan.c:3330
 try_to_free_pages+0x9dc/0xfd0 mm/vmscan.c:3565
 __perform_reclaim mm/page_alloc.c:4624 [inline]
 __alloc_pages_direct_reclaim mm/page_alloc.c:4645 [inline]
 __alloc_pages_slowpath+0x108a/0x2800 mm/page_alloc.c:5051
 __alloc_pages+0x45a/0x700 mm/page_alloc.c:5434
 vm_area_alloc_pages mm/vmalloc.c:2868 [inline]
 __vmalloc_area_node mm/vmalloc.c:2924 [inline]
 __vmalloc_node_range+0x5ab/0x8c0 mm/vmalloc.c:3029
 vmalloc_user+0x70/0x80 mm/vmalloc.c:3165
 vb2_vmalloc_alloc+0xee/0x330 drivers/media/common/videobuf2/videobuf2-vmalloc.c:47
 __vb2_buf_mem_alloc drivers/media/common/videobuf2/videobuf2-core.c:233 [inline]
 __vb2_queue_alloc+0x6f4/0x12d0 drivers/media/common/videobuf2/videobuf2-core.c:439
 vb2_core_create_bufs+0x496/0xaa0 drivers/media/common/videobuf2/videobuf2-core.c:946
 vb2_create_bufs+0x7d1/0x1080 drivers/media/common/videobuf2/videobuf2-v4l2.c:799
 v4l_create_bufs+0x1e2/0x340 drivers/media/v4l2-core/v4l2-ioctl.c:2072
 __video_do_ioctl+0xa44/0xe40 drivers/media/v4l2-core/v4l2-ioctl.c:2976
 video_usercopy+0xa87/0x1120 drivers/media/v4l2-core/v4l2-ioctl.c:3324
 v4l2_ioctl+0x181/0x1d0 drivers/media/v4l2-core/v4l2-dev.c:364
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7ff957439da9
Code: Unable to access opcode bytes at RIP 0x7ff957439d7f.
RSP: 002b:00007ff9559ba0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007ff957567f80 RCX: 00007ff957439da9
RDX: 0000000020000040 RSI: 00000000c100565c RDI: 0000000000000003
RBP: 00007ff95748647a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007ff957567f80 R15: 00007fff2a4d5358
 </TASK>
syz-executor.4 (9154) used greatest stack depth: 18552 bytes left

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/03/30 00:19 linux-5.15.y 9465fef4ae35 c52bcb23 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in __ntfs_clear_inode
* Struck through repros no longer work on HEAD.