syzbot


possible deadlock in ext4_truncate (2)

Status: upstream: reported C repro on 2025/08/25 08:51
Subsystems: ext4
[Documentation on labels]
Reported-by: syzbot+c5c9c223a721d7353490@syzkaller.appspotmail.com
First crash: 5d13h, last: 4d05h
Cause bisection: introduced by (bisect log) [merge commit]:
commit af96134dc8562f9fcbb8358af36f6086619a29ab
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date: Tue Jun 27 17:37:01 2023 +0000

  Merge tag 'rcu.2023.06.22a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu

Crash: possible deadlock in ext4_xattr_inode_iget (log)
Repro: C syz .config
  
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [ext4?] possible deadlock in ext4_truncate (2) 4 (7) 2025/08/26 03:46
Similar bugs (2)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in ext4_truncate ext4 4 4 243d 264d 0/29 closed as dup on 2024/12/12 23:40
linux-6.6 possible deadlock in ext4_truncate origin:lts-only 4 syz 6 26d 29d 0/2 upstream: reported syz repro on 2025/07/30 13:32
Last patch testing requests (2)
Created Duration User Patch Repo Result
2025/08/26 01:43 24m hdanton@sina.com patch upstream OK log
2025/08/25 10:42 17m hdanton@sina.com patch upstream report log

Sample crash report:
loop5: detected capacity change from 0 to 1024
EXT4-fs: Ignoring removed nobh option
============================================
WARNING: possible recursive locking detected
syzkaller #0 Not tainted
--------------------------------------------
syz.5.286/7060 is trying to acquire lock:
ffff888056de1590 (&ei->i_data_sem/3){++++}-{4:4}, at: ext4_truncate+0xddd/0x1210 fs/ext4/inode.c:4639

but task is already holding lock:
ffff888056de1f20 (&ei->i_data_sem/3){++++}-{4:4}, at: ext4_truncate+0xddd/0x1210 fs/ext4/inode.c:4639

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&ei->i_data_sem/3);
  lock(&ei->i_data_sem/3);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

5 locks held by syz.5.286/7060:
 #0: ffff888022bfe428 (sb_writers#4){.+.+}-{0:0}, at: vfs_truncate+0x336/0x6e0 fs/open.c:96
 #1: ffff888056de2090 (&sb->s_type->i_mutex_key#9){++++}-{4:4}, at: inode_lock_killable include/linux/fs.h:874 [inline]
 #1: ffff888056de2090 (&sb->s_type->i_mutex_key#9){++++}-{4:4}, at: do_truncate+0x146/0x230 fs/open.c:63
 #2: ffff888056de2230 (mapping.invalidate_lock#2){++++}-{4:4}, at: filemap_invalidate_lock include/linux/fs.h:924 [inline]
 #2: ffff888056de2230 (mapping.invalidate_lock#2){++++}-{4:4}, at: ext4_setattr+0xe11/0x2ae0 fs/ext4/inode.c:5954
 #3: ffff888056de1f20 (&ei->i_data_sem/3){++++}-{4:4}, at: ext4_truncate+0xddd/0x1210 fs/ext4/inode.c:4639
 #4: ffff888056de1d78 (&ei->xattr_sem){++++}-{4:4}, at: ext4_write_trylock_xattr fs/ext4/xattr.h:164 [inline]
 #4: ffff888056de1d78 (&ei->xattr_sem){++++}-{4:4}, at: ext4_try_to_expand_extra_isize fs/ext4/inode.c:6425 [inline]
 #4: ffff888056de1d78 (&ei->xattr_sem){++++}-{4:4}, at: __ext4_mark_inode_dirty+0x4ba/0x870 fs/ext4/inode.c:6506

stack backtrace:
CPU: 1 UID: 0 PID: 7060 Comm: syz.5.286 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_deadlock_bug+0x1e9/0x240 kernel/locking/lockdep.c:3041
 check_deadlock kernel/locking/lockdep.c:3093 [inline]
 validate_chain kernel/locking/lockdep.c:3895 [inline]
 __lock_acquire+0x1133/0x1ce0 kernel/locking/lockdep.c:5237
 lock_acquire kernel/locking/lockdep.c:5868 [inline]
 lock_acquire+0x179/0x350 kernel/locking/lockdep.c:5825
 down_write+0x92/0x200 kernel/locking/rwsem.c:1590
 ext4_truncate+0xddd/0x1210 fs/ext4/inode.c:4639
 ext4_evict_inode+0x7a8/0x18e0 fs/ext4/inode.c:261
 evict+0x3e6/0x920 fs/inode.c:810
 iput_final fs/inode.c:1897 [inline]
 iput fs/inode.c:1923 [inline]
 iput+0x521/0x880 fs/inode.c:1909
 ext4_xattr_set_entry+0x73c/0x1f00 fs/ext4/xattr.c:1839
 ext4_xattr_ibody_set+0x3d6/0x5d0 fs/ext4/xattr.c:2263
 ext4_xattr_move_to_block fs/ext4/xattr.c:2666 [inline]
 ext4_xattr_make_inode_space fs/ext4/xattr.c:2734 [inline]
 ext4_expand_extra_isize_ea+0x1487/0x1ab0 fs/ext4/xattr.c:2822
 __ext4_expand_extra_isize+0x346/0x480 fs/ext4/inode.c:6385
 ext4_try_to_expand_extra_isize fs/ext4/inode.c:6428 [inline]
 __ext4_mark_inode_dirty+0x544/0x870 fs/ext4/inode.c:6506
 ext4_ext_truncate+0xa3/0x300 fs/ext4/extents.c:4475
 ext4_truncate+0xe3b/0x1210 fs/ext4/inode.c:4643
 ext4_setattr+0x19f3/0x2ae0 fs/ext4/inode.c:6044
 notify_change+0x6a9/0x1230 fs/attr.c:552
 do_truncate+0x1d7/0x230 fs/open.c:68
 vfs_truncate+0x5d6/0x6e0 fs/open.c:118
 do_sys_truncate fs/open.c:141 [inline]
 __do_sys_truncate fs/open.c:153 [inline]
 __se_sys_truncate fs/open.c:151 [inline]
 __x64_sys_truncate+0x172/0x1e0 fs/open.c:151
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f63ad98ebe9
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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f63ae7fc038 EFLAGS: 00000246 ORIG_RAX: 000000000000004c
RAX: ffffffffffffffda RBX: 00007f63adbb5fa0 RCX: 00007f63ad98ebe9
RDX: 0000000000000000 RSI: 000000000000041a RDI: 00002000000000c0
RBP: 00007f63ada11e19 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f63adbb6038 R14: 00007f63adbb5fa0 R15: 00007fff7f328758
 </TASK>

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/08/24 15:25 upstream 8d245acc1e88 bf27483f .config console log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro (clean fs)] ci-upstream-kasan-badwrites-root possible deadlock in ext4_truncate
2025/08/24 12:22 upstream 8d245acc1e88 bf27483f .config console log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro (clean fs)] ci-upstream-kasan-badwrites-root possible deadlock in ext4_truncate
2025/08/23 07:42 upstream 6debb6904172 bf27483f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root possible deadlock in ext4_truncate
* Struck through repros no longer work on HEAD.