[v6.1] possible deadlock in ext4_evict_inode (3)

0 views
Skip to first unread message

syzbot

unread,
Apr 3, 2024, 6:45:29 AMApr 3
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: e5cd595e23c1 Linux 6.1.83
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=130dccc5180000
kernel config: https://syzkaller.appspot.com/x/.config?x=638c7154137d2582
dashboard link: https://syzkaller.appspot.com/bug?extid=7e989d2df8b9013c1d98
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/a9b3de36bd43/disk-e5cd595e.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/2af9bc6e6ea4/vmlinux-e5cd595e.xz
kernel image: https://storage.googleapis.com/syzbot-assets/7f58381bafc0/Image-e5cd595e.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+7e989d...@syzkaller.appspotmail.com

======================================================
WARNING: possible circular locking dependency detected
6.1.83-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.3/7470 is trying to acquire lock:
ffff0000fa036650 (sb_internal){.+.+}-{0:0}, at: __sb_start_write include/linux/fs.h:1891 [inline]
ffff0000fa036650 (sb_internal){.+.+}-{0:0}, at: sb_start_intwrite include/linux/fs.h:2013 [inline]
ffff0000fa036650 (sb_internal){.+.+}-{0:0}, at: ext4_evict_inode+0x408/0x12cc fs/ext4/inode.c:240

but task is already holding lock:
ffff0000db50cb98 (&sbi->s_writepages_rwsem){++++}-{0:0}, at: ext4_ext_migrate+0x234/0xee4 fs/ext4/migrate.c:437

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&sbi->s_writepages_rwsem){++++}-{0:0}:
percpu_down_read+0x78/0x304 include/linux/percpu-rwsem.h:51
ext4_writepages+0x18c/0x32b4 fs/ext4/inode.c:2703
do_writepages+0x2e8/0x56c mm/page-writeback.c:2469
filemap_fdatawrite_wbc+0x124/0x174 mm/filemap.c:388
__filemap_fdatawrite_range mm/filemap.c:421 [inline]
filemap_write_and_wait_range+0x17c/0x268 mm/filemap.c:674
__iomap_dio_rw+0x864/0x1b34 fs/iomap/direct-io.c:573
iomap_dio_rw+0x5c/0xa8 fs/iomap/direct-io.c:690
ext4_dio_read_iter fs/ext4/file.c:94 [inline]
ext4_file_read_iter+0x3a0/0x4d4 fs/ext4/file.c:145
lo_rw_aio+0x91c/0xc84
loop_handle_cmd drivers/block/loop.c:1909 [inline]
loop_process_work+0x68c/0x24a4 drivers/block/loop.c:1944
loop_workfn+0x54/0x68 drivers/block/loop.c:1968
process_one_work+0x7ac/0x1404 kernel/workqueue.c:2292
worker_thread+0x8e4/0xfec kernel/workqueue.c:2439
kthread+0x250/0x2d8 kernel/kthread.c:376
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:864

-> #2 (&sb->s_type->i_mutex_key#9){++++}-{3:3}:
down_read+0x64/0x308 kernel/locking/rwsem.c:1520
inode_lock_shared include/linux/fs.h:768 [inline]
ext4_bmap+0x58/0x35c fs/ext4/inode.c:3176
bmap+0xa8/0xe8 fs/inode.c:1842
jbd2_journal_bmap fs/jbd2/journal.c:977 [inline]
__jbd2_journal_erase fs/jbd2/journal.c:1794 [inline]
jbd2_journal_flush+0x4bc/0xa5c fs/jbd2/journal.c:2496
ext4_ioctl_checkpoint fs/ext4/ioctl.c:1086 [inline]
__ext4_ioctl fs/ext4/ioctl.c:1594 [inline]
ext4_ioctl+0x3834/0x6afc fs/ext4/ioctl.c:1614
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl fs/ioctl.c:856 [inline]
__arm64_sys_ioctl+0x14c/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 (&journal->j_checkpoint_mutex){+.+.}-{3:3}:
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
mutex_lock_io_nested+0x6c/0x88 kernel/locking/mutex.c:833
__jbd2_log_wait_for_space+0x1a4/0x5cc fs/jbd2/checkpoint.c:71
add_transaction_credits+0x7dc/0xafc fs/jbd2/transaction.c:298
start_this_handle+0x5c4/0x13ac fs/jbd2/transaction.c:422
jbd2__journal_start+0x298/0x544 fs/jbd2/transaction.c:520
__ext4_journal_start_sb+0x304/0x6f4 fs/ext4/ext4_jbd2.c:105
__ext4_journal_start fs/ext4/ext4_jbd2.h:326 [inline]
ext4_evict_inode+0x7cc/0x12cc fs/ext4/inode.c:251
evict+0x260/0x68c fs/inode.c:666
iput_final fs/inode.c:1791 [inline]
iput+0x7c0/0x8a4 fs/inode.c:1817
do_unlinkat+0x530/0x70c fs/namei.c:4399
__do_sys_unlinkat fs/namei.c:4435 [inline]
__se_sys_unlinkat fs/namei.c:4428 [inline]
__arm64_sys_unlinkat+0xcc/0xfc fs/namei.c:4428
__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 (sb_internal){.+.+}-{0:0}:
check_prev_add kernel/locking/lockdep.c:3090 [inline]
check_prevs_add kernel/locking/lockdep.c:3209 [inline]
validate_chain kernel/locking/lockdep.c:3825 [inline]
__lock_acquire+0x3338/0x7680 kernel/locking/lockdep.c:5049
lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5662
percpu_down_read+0x78/0x304 include/linux/percpu-rwsem.h:51
__sb_start_write include/linux/fs.h:1891 [inline]
sb_start_intwrite include/linux/fs.h:2013 [inline]
ext4_evict_inode+0x408/0x12cc fs/ext4/inode.c:240
evict+0x260/0x68c fs/inode.c:666
iput_final fs/inode.c:1791 [inline]
iput+0x7c0/0x8a4 fs/inode.c:1817
ext4_ext_migrate+0xc3c/0xee4 fs/ext4/migrate.c:587
ext4_ioctl_setflags fs/ext4/ioctl.c:695 [inline]
ext4_fileattr_set+0xc1c/0x12c8 fs/ext4/ioctl.c:1008
vfs_fileattr_set+0x70c/0xad4 fs/ioctl.c:696
do_vfs_ioctl+0x14cc/0x26f8
__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

other info that might help us debug this:

Chain exists of:
sb_internal --> &sb->s_type->i_mutex_key#9 --> &sbi->s_writepages_rwsem

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&sbi->s_writepages_rwsem);
lock(&sb->s_type->i_mutex_key#9);
lock(&sbi->s_writepages_rwsem);
lock(sb_internal);

*** DEADLOCK ***

3 locks held by syz-executor.3/7470:
#0: ffff0000fa036460 (sb_writers#3){.+.+}-{0:0}, at: mnt_want_write_file+0x64/0x1e8 fs/namespace.c:437
#1: ffff0000f1be2c20 (&sb->s_type->i_mutex_key#9){++++}-{3:3}, at: inode_lock include/linux/fs.h:758 [inline]
#1: ffff0000f1be2c20 (&sb->s_type->i_mutex_key#9){++++}-{3:3}, at: vfs_fileattr_set+0x110/0xad4 fs/ioctl.c:681
#2: ffff0000db50cb98 (&sbi->s_writepages_rwsem){++++}-{0:0}, at: ext4_ext_migrate+0x234/0xee4 fs/ext4/migrate.c:437

stack backtrace:
CPU: 1 PID: 7470 Comm: syz-executor.3 Not tainted 6.1.83-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
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/0x5c 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:3825 [inline]
__lock_acquire+0x3338/0x7680 kernel/locking/lockdep.c:5049
lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5662
percpu_down_read+0x78/0x304 include/linux/percpu-rwsem.h:51
__sb_start_write include/linux/fs.h:1891 [inline]
sb_start_intwrite include/linux/fs.h:2013 [inline]
ext4_evict_inode+0x408/0x12cc fs/ext4/inode.c:240
evict+0x260/0x68c fs/inode.c:666
iput_final fs/inode.c:1791 [inline]
iput+0x7c0/0x8a4 fs/inode.c:1817
ext4_ext_migrate+0xc3c/0xee4 fs/ext4/migrate.c:587
ext4_ioctl_setflags fs/ext4/ioctl.c:695 [inline]
ext4_fileattr_set+0xc1c/0x12c8 fs/ext4/ioctl.c:1008
vfs_fileattr_set+0x70c/0xad4 fs/ioctl.c:696
do_vfs_ioctl+0x14cc/0x26f8
__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


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