syz-executor.4: attempt to access beyond end of device loop4: rw=2049, sector=77824, nr_sectors = 2048 limit=63271 syz-executor.4: attempt to access beyond end of device loop4: rw=2049, sector=79872, nr_sectors = 2048 limit=63271 ====================================================== WARNING: possible circular locking dependency detected 6.3.0-syzkaller-11301-g1ae78a14516b #0 Not tainted ------------------------------------------------------ syz-executor.4/18476 is trying to acquire lock: ffff888075b7c1a0 (&iint->mutex){+.+.}-{3:3}, at: ima_check_last_writer security/integrity/ima/ima_main.c:165 [inline] ffff888075b7c1a0 (&iint->mutex){+.+.}-{3:3}, at: ima_file_free+0x110/0x3c0 security/integrity/ima/ima_main.c:199 but task is already holding lock: ffff888039b2c448 (&sbi->node_write){++++}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2087 [inline] ffff888039b2c448 (&sbi->node_write){++++}-{3:3}, at: f2fs_write_single_data_page+0xa10/0x1d50 fs/f2fs/data.c:2842 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 (&sbi->node_write){++++}-{3:3}: reacquire_held_locks+0x3aa/0x660 kernel/locking/lockdep.c:5216 __lock_release kernel/locking/lockdep.c:5405 [inline] lock_release+0x36f/0x9d0 kernel/locking/lockdep.c:5711 up_write+0x79/0x580 kernel/locking/rwsem.c:1625 f2fs_write_checkpoint+0x13a4/0x1f90 fs/f2fs/checkpoint.c:1651 f2fs_issue_checkpoint+0x2e6/0x4d0 fs/f2fs/checkpoint.c:1858 f2fs_do_sync_file+0xd52/0x1ae0 fs/f2fs/file.c:325 generic_write_sync include/linux/fs.h:2469 [inline] f2fs_file_write_iter+0x70d/0x2520 fs/f2fs/file.c:4747 call_write_iter include/linux/fs.h:1868 [inline] new_sync_write fs/read_write.c:491 [inline] vfs_write+0x7ec/0xc10 fs/read_write.c:584 ksys_write+0x1a0/0x2c0 fs/read_write.c:637 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #2 (&sbi->cp_rwsem){++++}-{3:3}: lock_acquire+0x1e3/0x520 kernel/locking/lockdep.c:5691 down_read+0x3d/0x50 kernel/locking/rwsem.c:1520 f2fs_down_read fs/f2fs/f2fs.h:2087 [inline] f2fs_lock_op fs/f2fs/f2fs.h:2130 [inline] f2fs_do_truncate_blocks+0x1bb/0xc50 fs/f2fs/file.c:686 f2fs_truncate_blocks+0x10d/0x2f0 fs/f2fs/file.c:749 f2fs_truncate+0x3d9/0x740 fs/f2fs/file.c:799 f2fs_setattr+0xbf1/0x1270 fs/f2fs/file.c:1006 notify_change+0xc8b/0xf40 fs/attr.c:483 ovl_do_notify_change fs/overlayfs/overlayfs.h:144 [inline] ovl_set_size fs/overlayfs/copy_up.c:332 [inline] ovl_copy_up_metadata+0x7c9/0xba0 fs/overlayfs/copy_up.c:651 ovl_copy_up_tmpfile fs/overlayfs/copy_up.c:797 [inline] ovl_do_copy_up fs/overlayfs/copy_up.c:876 [inline] ovl_copy_up_one fs/overlayfs/copy_up.c:1048 [inline] ovl_copy_up_flags+0x2bf3/0x3d60 fs/overlayfs/copy_up.c:1094 ovl_rename+0x3bf/0x14c0 fs/overlayfs/dir.c:1139 vfs_rename+0xb1b/0xfa0 fs/namei.c:4849 do_renameat2+0xd78/0x1660 fs/namei.c:5002 __do_sys_renameat2 fs/namei.c:5035 [inline] __se_sys_renameat2 fs/namei.c:5032 [inline] __x64_sys_renameat2+0xd2/0xe0 fs/namei.c:5032 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #1 (mapping.invalidate_lock#6){++++}-{3:3}: lock_acquire+0x1e3/0x520 kernel/locking/lockdep.c:5691 down_read+0x3d/0x50 kernel/locking/rwsem.c:1520 filemap_invalidate_lock_shared include/linux/fs.h:830 [inline] page_cache_ra_unbounded+0xf1/0x7c0 mm/readahead.c:226 page_cache_sync_readahead include/linux/pagemap.h:1211 [inline] filemap_get_pages+0x49c/0x20c0 mm/filemap.c:2595 filemap_read+0x45a/0x1170 mm/filemap.c:2690 f2fs_file_read_iter+0x159/0x8d0 fs/f2fs/file.c:4406 __kernel_read+0x422/0x8a0 fs/read_write.c:428 integrity_kernel_read+0xb0/0xf0 security/integrity/iint.c:192 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+0x1643/0x1d20 security/integrity/ima/ima_crypto.c:573 ima_collect_measurement+0x3a7/0x880 security/integrity/ima/ima_api.c:293 process_measurement+0xfdb/0x1ce0 security/integrity/ima/ima_main.c:341 ima_file_check+0xf1/0x170 security/integrity/ima/ima_main.c:539 do_open fs/namei.c:3638 [inline] path_openat+0x280a/0x3170 fs/namei.c:3791 do_filp_open+0x234/0x490 fs/namei.c:3818 do_sys_openat2+0x13f/0x500 fs/open.c:1356 do_sys_open fs/open.c:1372 [inline] __do_sys_open fs/open.c:1380 [inline] __se_sys_open fs/open.c:1376 [inline] __x64_sys_open+0x225/0x270 fs/open.c:1376 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd -> #0 (&iint->mutex){+.+.}-{3:3}: check_prev_add kernel/locking/lockdep.c:3108 [inline] check_prevs_add kernel/locking/lockdep.c:3227 [inline] validate_chain+0x166b/0x58e0 kernel/locking/lockdep.c:3842 __lock_acquire+0x1295/0x2000 kernel/locking/lockdep.c:5074 lock_acquire+0x1e3/0x520 kernel/locking/lockdep.c:5691 __mutex_lock_common+0x1d8/0x2530 kernel/locking/mutex.c:603 __mutex_lock kernel/locking/mutex.c:747 [inline] mutex_lock_nested+0x1b/0x20 kernel/locking/mutex.c:799 ima_check_last_writer security/integrity/ima/ima_main.c:165 [inline] ima_file_free+0x110/0x3c0 security/integrity/ima/ima_main.c:199 __fput+0x32e/0x890 fs/file_table.c:315 task_work_run+0x24a/0x300 kernel/task_work.c:179 get_signal+0x1606/0x17e0 kernel/signal.c:2650 arch_do_signal_or_restart+0x91/0x670 arch/x86/kernel/signal.c:306 exit_to_user_mode_loop+0x6a/0x100 kernel/entry/common.c:168 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline] syscall_exit_to_user_mode+0x64/0x280 kernel/entry/common.c:297 do_syscall_64+0x4d/0xc0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd other info that might help us debug this: Chain exists of: &iint->mutex --> &sbi->cp_rwsem --> &sbi->node_write Possible unsafe locking scenario: CPU0 CPU1 ---- ---- rlock(&sbi->node_write); lock(&sbi->cp_rwsem); lock(&sbi->node_write); lock(&iint->mutex); *** DEADLOCK *** 1 lock held by syz-executor.4/18476: #0: ffff888039b2c448 (&sbi->node_write){++++}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2087 [inline] #0: ffff888039b2c448 (&sbi->node_write){++++}-{3:3}, at: f2fs_write_single_data_page+0xa10/0x1d50 fs/f2fs/data.c:2842 stack backtrace: CPU: 1 PID: 18476 Comm: syz-executor.4 Not tainted 6.3.0-syzkaller-11301-g1ae78a14516b #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/14/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106 check_noncircular+0x2fe/0x3b0 kernel/locking/lockdep.c:2188 check_prev_add kernel/locking/lockdep.c:3108 [inline] check_prevs_add kernel/locking/lockdep.c:3227 [inline] validate_chain+0x166b/0x58e0 kernel/locking/lockdep.c:3842 __lock_acquire+0x1295/0x2000 kernel/locking/lockdep.c:5074 lock_acquire+0x1e3/0x520 kernel/locking/lockdep.c:5691 __mutex_lock_common+0x1d8/0x2530 kernel/locking/mutex.c:603 __mutex_lock kernel/locking/mutex.c:747 [inline] mutex_lock_nested+0x1b/0x20 kernel/locking/mutex.c:799 ima_check_last_writer security/integrity/ima/ima_main.c:165 [inline] ima_file_free+0x110/0x3c0 security/integrity/ima/ima_main.c:199 __fput+0x32e/0x890 fs/file_table.c:315 task_work_run+0x24a/0x300 kernel/task_work.c:179 get_signal+0x1606/0x17e0 kernel/signal.c:2650 arch_do_signal_or_restart+0x91/0x670 arch/x86/kernel/signal.c:306 exit_to_user_mode_loop+0x6a/0x100 kernel/entry/common.c:168 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline] syscall_exit_to_user_mode+0x64/0x280 kernel/entry/common.c:297 do_syscall_64+0x4d/0xc0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f1ac308c169 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 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:00007f1ac3d50168 EFLAGS: 00000246 ORIG_RAX: 0000000000000148 RAX: fffffffffffffffb RBX: 00007f1ac31abf80 RCX: 00007f1ac308c169 RDX: 0000000000000001 RSI: 0000000020000240 RDI: 0000000000000004 RBP: 00007f1ac30e7ca1 R08: 0000000000000000 R09: 0000000000000003 R10: 0000000000001400 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffdb09ba08f R14: 00007f1ac3d50300 R15: 0000000000022000