NILFS error (device loop4): nilfs_bmap_lookup_contig: broken bmap (inode number=16) ====================================================== WARNING: possible circular locking dependency detected 6.1.0-rc4-syzkaller-00015-gf141df371335 #0 Not tainted ------------------------------------------------------ syz-executor.4/6591 is trying to acquire lock: ffff88801c596090 (&nilfs->ns_sem){++++}-{3:3}, at: nilfs_set_error fs/nilfs2/super.c:92 [inline] ffff88801c596090 (&nilfs->ns_sem){++++}-{3:3}, at: __nilfs_error+0x1d2/0x4c0 fs/nilfs2/super.c:137 but task is already holding lock: ffff8880318f5870 (&dat_lock_key){.+.+}-{3:3}, at: nilfs_get_block+0x1f7/0x8d0 fs/nilfs2/inode.c:84 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (&dat_lock_key){.+.+}-{3:3}: lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668 down_read+0x39/0x50 kernel/locking/rwsem.c:1509 nilfs_count_free_blocks+0x63/0x110 fs/nilfs2/the_nilfs.c:693 nilfs_set_log_cursor fs/nilfs2/super.c:236 [inline] nilfs_cleanup_super+0x11e/0x410 fs/nilfs2/super.c:318 nilfs_put_super+0x96/0x150 fs/nilfs2/super.c:472 generic_shutdown_super+0x130/0x310 fs/super.c:492 kill_block_super+0x79/0xd0 fs/super.c:1428 deactivate_locked_super+0xa7/0xf0 fs/super.c:332 cleanup_mnt+0x494/0x520 fs/namespace.c:1186 task_work_run+0x243/0x300 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0x124/0x150 kernel/entry/common.c:171 exit_to_user_mode_prepare+0xb2/0x140 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x26/0x60 kernel/entry/common.c:296 do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #0 (&nilfs->ns_sem){++++}-{3:3}: check_prev_add kernel/locking/lockdep.c:3097 [inline] check_prevs_add kernel/locking/lockdep.c:3216 [inline] validate_chain+0x1898/0x6ae0 kernel/locking/lockdep.c:3831 __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055 lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668 down_write+0x9c/0x270 kernel/locking/rwsem.c:1562 nilfs_set_error fs/nilfs2/super.c:92 [inline] __nilfs_error+0x1d2/0x4c0 fs/nilfs2/super.c:137 nilfs_bmap_convert_error fs/nilfs2/bmap.c:35 [inline] nilfs_bmap_lookup_contig+0x132/0x150 fs/nilfs2/bmap.c:95 nilfs_get_block+0x240/0x8d0 fs/nilfs2/inode.c:85 do_mpage_readpage+0x970/0x1c50 fs/mpage.c:208 mpage_readahead+0x210/0x380 fs/mpage.c:361 read_pages+0x169/0x9c0 mm/readahead.c:161 page_cache_ra_unbounded+0x703/0x820 mm/readahead.c:270 page_cache_sync_readahead include/linux/pagemap.h:1213 [inline] filemap_get_pages+0x465/0x10d0 mm/filemap.c:2581 filemap_read+0x3cf/0xea0 mm/filemap.c:2675 __kernel_read+0x3fc/0x830 fs/read_write.c:428 integrity_kernel_read+0xac/0xf0 security/integrity/iint.c:199 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:485 [inline] ima_calc_file_shash security/integrity/ima/ima_crypto.c:516 [inline] ima_calc_file_hash+0x178f/0x1ca0 security/integrity/ima/ima_crypto.c:573 ima_collect_measurement+0x444/0x8c0 security/integrity/ima/ima_api.c:292 process_measurement+0xf4b/0x1bd0 security/integrity/ima/ima_main.c:337 ima_file_check+0xd8/0x130 security/integrity/ima/ima_main.c:517 do_open fs/namei.c:3559 [inline] path_openat+0x2642/0x2df0 fs/namei.c:3713 do_filp_open+0x264/0x4f0 fs/namei.c:3740 do_sys_openat2+0x124/0x4e0 fs/open.c:1310 do_sys_open fs/open.c:1326 [inline] __do_sys_open fs/open.c:1334 [inline] __se_sys_open fs/open.c:1330 [inline] __x64_sys_open+0x221/0x270 fs/open.c:1330 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+0x63/0xcd other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&dat_lock_key); lock(&nilfs->ns_sem); lock(&dat_lock_key); lock(&nilfs->ns_sem); *** DEADLOCK *** 4 locks held by syz-executor.4/6591: #0: ffff8880330d6460 (sb_writers#24){.+.+}-{0:0}, at: mnt_want_write+0x3b/0x80 fs/namespace.c:393 #1: ffff888017aad500 (&iint->mutex){+.+.}-{3:3}, at: process_measurement+0x7ab/0x1bd0 security/integrity/ima/ima_main.c:260 #2: ffff888032fdddf8 (mapping.invalidate_lock#4){.+.+}-{3:3}, at: filemap_invalidate_lock_shared include/linux/fs.h:811 [inline] #2: ffff888032fdddf8 (mapping.invalidate_lock#4){.+.+}-{3:3}, at: page_cache_ra_unbounded+0xe9/0x820 mm/readahead.c:226 #3: ffff8880318f5870 (&dat_lock_key){.+.+}-{3:3}, at: nilfs_get_block+0x1f7/0x8d0 fs/nilfs2/inode.c:84 stack backtrace: CPU: 0 PID: 6591 Comm: syz-executor.4 Not tainted 6.1.0-rc4-syzkaller-00015-gf141df371335 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106 check_noncircular+0x2cc/0x390 kernel/locking/lockdep.c:2177 check_prev_add kernel/locking/lockdep.c:3097 [inline] check_prevs_add kernel/locking/lockdep.c:3216 [inline] validate_chain+0x1898/0x6ae0 kernel/locking/lockdep.c:3831 __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055 lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668 down_write+0x9c/0x270 kernel/locking/rwsem.c:1562 nilfs_set_error fs/nilfs2/super.c:92 [inline] __nilfs_error+0x1d2/0x4c0 fs/nilfs2/super.c:137 nilfs_bmap_convert_error fs/nilfs2/bmap.c:35 [inline] nilfs_bmap_lookup_contig+0x132/0x150 fs/nilfs2/bmap.c:95 nilfs_get_block+0x240/0x8d0 fs/nilfs2/inode.c:85 do_mpage_readpage+0x970/0x1c50 fs/mpage.c:208 mpage_readahead+0x210/0x380 fs/mpage.c:361 read_pages+0x169/0x9c0 mm/readahead.c:161 page_cache_ra_unbounded+0x703/0x820 mm/readahead.c:270 page_cache_sync_readahead include/linux/pagemap.h:1213 [inline] filemap_get_pages+0x465/0x10d0 mm/filemap.c:2581 filemap_read+0x3cf/0xea0 mm/filemap.c:2675 __kernel_read+0x3fc/0x830 fs/read_write.c:428 integrity_kernel_read+0xac/0xf0 security/integrity/iint.c:199 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:485 [inline] ima_calc_file_shash security/integrity/ima/ima_crypto.c:516 [inline] ima_calc_file_hash+0x178f/0x1ca0 security/integrity/ima/ima_crypto.c:573 ima_collect_measurement+0x444/0x8c0 security/integrity/ima/ima_api.c:292 process_measurement+0xf4b/0x1bd0 security/integrity/ima/ima_main.c:337 ima_file_check+0xd8/0x130 security/integrity/ima/ima_main.c:517 do_open fs/namei.c:3559 [inline] path_openat+0x2642/0x2df0 fs/namei.c:3713 do_filp_open+0x264/0x4f0 fs/namei.c:3740 do_sys_openat2+0x124/0x4e0 fs/open.c:1310 do_sys_open fs/open.c:1326 [inline] __do_sys_open fs/open.c:1334 [inline] __se_sys_open fs/open.c:1330 [inline] __x64_sys_open+0x221/0x270 fs/open.c:1330 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+0x63/0xcd RIP: 0033:0x7f74d428b639 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 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f74d4fa2168 EFLAGS: 00000246 ORIG_RAX: 0000000000000002 RAX: ffffffffffffffda RBX: 00007f74d43ac120 RCX: 00007f74d428b639 RDX: 0000000000000000 RSI: 0000000000000282 RDI: 00000000200001c0 RBP: 00007f74d42e67e1 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fff9978253f R14: 00007f74d4fa2300 R15: 0000000000022000 Remounting filesystem read-only NILFS (loop4): bad btree node (ino=16, blocknr=15): level = 1, flags = 0x0, nchildren = 8201 NILFS error (device loop4): nilfs_bmap_lookup_contig: broken bmap (inode number=16) NILFS (loop4): bad btree node (ino=16, blocknr=15): level = 1, flags = 0x0, nchildren = 8201 NILFS error (device loop4): nilfs_bmap_lookup_contig: broken bmap (inode number=16) NILFS (loop4): bad btree node (ino=16, blocknr=15): level = 1, flags = 0x0, nchildren = 8201 NILFS error (device loop4): nilfs_bmap_lookup_contig: broken bmap (inode number=16) NILFS (loop4): bad btree node (ino=16, blocknr=15): level = 1, flags = 0x0, nchildren = 8201 NILFS error (device loop4): nilfs_bmap_lookup_contig: broken bmap (inode number=16) NILFS (loop4): bad btree node (ino=16, blocknr=15): level = 1, flags = 0x0, nchildren = 8201 NILFS error (device loop4): nilfs_bmap_lookup_contig: broken bmap (inode number=16) NILFS (loop4): bad btree node (ino=16, blocknr=15): level = 1, flags = 0x0, nchildren = 8201 NILFS error (device loop4): nilfs_bmap_lookup_contig: broken bmap (inode number=16) NILFS (loop4): bad btree node (ino=16, blocknr=15): level = 1, flags = 0x0, nchildren = 8201 NILFS error (device loop4): nilfs_bmap_lookup_contig: broken bmap (inode number=16) NILFS (loop4): bad btree node (ino=16, blocknr=15): level = 1, flags = 0x0, nchildren = 8201 NILFS error (device loop4): nilfs_bmap_lookup_contig: broken bmap (inode number=16) NILFS (loop4): bad btree node (ino=16, blocknr=15): level = 1, flags = 0x0, nchildren = 8201 NILFS error (device loop4): nilfs_bmap_lookup_contig: broken bmap (inode number=16) NILFS (loop4): bad btree node (ino=16, blocknr=15): level = 1, flags = 0x0, nchildren = 8201 NILFS error (device loop4): nilfs_bmap_lookup_contig: broken bmap (inode number=16) NILFS (loop4): bad btree node (ino=16, blocknr=15): level = 1, flags = 0x0, nchildren = 8201 NILFS error (device loop4): nilfs_bmap_lookup_contig: broken bmap (inode number=16) NILFS (loop4): bad btree node (ino=16, blocknr=15): level = 1, flags = 0x0, nchildren = 8201 NILFS error (device loop4): nilfs_bmap_lookup_contig: broken bmap (inode number=16) NILFS (loop4): bad btree node (ino=16, blocknr=15): level = 1, flags = 0x0, nchildren = 8201 NILFS error (device loop4): nilfs_bmap_lookup_contig: broken bmap (inode number=16) NILFS (loop4): bad btree node (ino=16, blocknr=15): level = 1, flags = 0x0, nchildren = 8201 NILFS error (device loop4): nilfs_bmap_lookup_contig: broken bmap (inode number=16) NILFS (loop4): bad btree node (ino=16, blocknr=15): level = 1, flags = 0x0, nchildren = 8201 NILFS error (device loop4): nilfs_bmap_lookup_contig: broken bmap (inode number=16) NILFS (loop4): bad btree node (ino=16, blocknr=15): level = 1, flags = 0x0, nchildren = 8201 NILFS error (device loop4): nilfs_bmap_last_key: broken bmap (inode number=16) NILFS (loop4): error -5 truncating bmap (ino=16) syz-executor.4 (6591) used greatest stack depth: 12632 bytes left