syzbot


possible deadlock in iterate_dir (3)

Status: upstream: reported on 2025/09/14 06:44
Subsystems: btrfs
[Documentation on labels]
Reported-by: syzbot+e290013facb5d5159eca@syzkaller.appspotmail.com
First crash: 212d, last: 16h47m
✨ AI Jobs (1)
ID Workflow Result Correct Bug Created Started Finished Revision Error
4e7a532c-50c3-4339-a178-c49e9ca4191b repro 💥 possible deadlock in iterate_dir (3) 2026/03/10 12:20 2026/03/10 12:20 2026/03/10 12:20 5c03941b7fba0fd3b0326afc981322c89fe9ba52+ unexpected git log output: "warning: unable to access '/root/.config/git/attributes': Permission denied\nwarning: unable to access '/root/.config/git/attributes': Permission denied\nb69053dd3ffbc0d2dedbbc86182cdef6f641fe1b\nwifi: mt76: Remove blank line after mt792x firmware version dmesg\nskhan@linuxfoundation.org\nShuah Khan\nWed Dec 31 16:46:26 2025 -0700\naf7809f037e6e56f63a4d66b6a02826ce786af2c\nWed Dec 31 17:03:35 2025 -0800\nAn extra blank line gets printed after printing firmware version\nbecause the build date is null terminated. Remove the \"\\n\" from\ndev_info() calls to print firmware version and build date to fix\nthe problem.\n\nReported-by: Mario Limonciello <superm1@gmail.com>\nSigned-off-by: Shuah Khan <skhan@linuxfoundation.org>\nSigned-off-by: Linus Torvalds <torvalds@linux-foundation.org>\n"
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [btrfs?] possible deadlock in iterate_dir (3) 0 (1) 2025/09/14 06:44
Similar bugs (10)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in iterate_dir (3) origin:lts-only 4 C inconclusive 9 1d12h 448d 0/3 upstream: reported C repro on 2025/01/16 11:46
linux-5.15 possible deadlock in iterate_dir (3) missing-backport origin:upstream 4 C error 21 65d 737d 0/3 upstream: reported C repro on 2024/04/03 07:56
upstream possible deadlock in iterate_dir (2) fs 4 1 462d 454d 0/29 auto-obsoleted due to no activity on 2025/04/12 17:38
linux-6.1 possible deadlock in iterate_dir (2) 4 2 715d 740d 0/3 auto-obsoleted due to no activity on 2024/08/02 17:42
linux-6.1 possible deadlock in iterate_dir 4 2 995d 1001d 0/3 auto-obsoleted due to no activity on 2023/10/27 20:39
linux-4.14 possible deadlock in iterate_dir ubifs 4 C 11375 1130d 2125d 0/1 upstream: reported C repro on 2020/06/15 06:16
linux-5.15 possible deadlock in iterate_dir (2) 4 2 862d 955d 0/3 auto-obsoleted due to no activity on 2024/03/08 13:21
linux-4.19 possible deadlock in iterate_dir 4 1 2296d 2296d 0/1 auto-closed as invalid on 2020/04/24 15:06
upstream possible deadlock in iterate_dir fs 4 23 960d 1202d 0/29 auto-obsoleted due to no activity on 2023/12/01 22:38
linux-5.15 possible deadlock in iterate_dir 4 1 1109d 1109d 0/3 auto-obsoleted due to no activity on 2023/07/25 13:55

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.4.1326/16680 is trying to acquire lock:
ffff8880345d9db0 (&mm->mmap_lock){++++}-{4:4}, at: mmap_read_lock_killable+0x1d/0x70 include/linux/mmap_lock.h:601

but task is already holding lock:
ffff888060d0a498 (&type->i_mutex_dir_key#5){++++}-{4:4}, at: iterate_dir+0x29e/0x580 fs/readdir.c:101

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #5 (&type->i_mutex_dir_key#5){++++}-{4:4}:
       down_read+0x97/0x200 kernel/locking/rwsem.c:1537
       inode_lock_shared include/linux/fs.h:1043 [inline]
       lookup_slow+0x46/0x70 fs/namei.c:1932
       walk_component fs/namei.c:2279 [inline]
       lookup_last fs/namei.c:2786 [inline]
       path_lookupat+0x3f5/0x8c0 fs/namei.c:2810
       filename_lookup+0x256/0x5d0 fs/namei.c:2839
       kern_path+0x3d/0x150 fs/namei.c:3046
       is_same_device fs/btrfs/volumes.c:763 [inline]
       device_list_add+0xfd1/0x2280 fs/btrfs/volumes.c:897
       btrfs_scan_one_device+0x3ef/0x680 fs/btrfs/volumes.c:1498
       btrfs_get_tree_super fs/btrfs/super.c:1858 [inline]
       btrfs_get_tree_subvol fs/btrfs/super.c:2087 [inline]
       btrfs_get_tree+0x4ab/0x1930 fs/btrfs/super.c:2121
       vfs_get_tree+0x92/0x2a0 fs/super.c:1754
       fc_mount fs/namespace.c:1193 [inline]
       do_new_mount_fc fs/namespace.c:3763 [inline]
       do_new_mount+0x341/0xd30 fs/namespace.c:3839
       do_mount fs/namespace.c:4172 [inline]
       __do_sys_mount fs/namespace.c:4361 [inline]
       __se_sys_mount+0x31d/0x420 fs/namespace.c:4338
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #4 (&fs_devs->device_list_mutex){+.+.}-{4:4}:
       __mutex_lock_common kernel/locking/rtmutex_api.c:533 [inline]
       mutex_lock_nested+0x5a/0x1d0 kernel/locking/rtmutex_api.c:552
       insert_dev_extents fs/btrfs/block-group.c:2838 [inline]
       btrfs_create_pending_block_groups+0x77b/0x1b40 fs/btrfs/block-group.c:2889
       __btrfs_end_transaction+0x140/0x640 fs/btrfs/transaction.c:1080
       btrfs_inc_block_group_ro+0x647/0x7c0 fs/btrfs/block-group.c:3181
       btrfs_relocate_block_group+0x276/0xa60 fs/btrfs/relocation.c:5367
       btrfs_relocate_chunk+0x115/0x830 fs/btrfs/volumes.c:3590
       __btrfs_balance+0x1dbf/0x2af0 fs/btrfs/volumes.c:4501
       btrfs_balance+0xafa/0x11f0 fs/btrfs/volumes.c:4888
       btrfs_ioctl_balance+0x3d6/0x610 fs/btrfs/ioctl.c:3452
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:597 [inline]
       __se_sys_ioctl+0xff/0x170 fs/ioctl.c:583
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #3 (btrfs_trans_num_extwriters){++++}-{0:0}:
       join_transaction+0x1a4/0xc90 fs/btrfs/transaction.c:323
       start_transaction+0x6b9/0x1650 fs/btrfs/transaction.c:708
       btrfs_rebuild_free_space_tree+0xbb/0x6e0 fs/btrfs/free-space-tree.c:1335
       btrfs_start_pre_rw_mount+0x1529/0x1f20 fs/btrfs/disk-io.c:3071
       open_ctree+0x2e07/0x4220 fs/btrfs/disk-io.c:3668
       btrfs_fill_super fs/btrfs/super.c:981 [inline]
       btrfs_get_tree_super fs/btrfs/super.c:1944 [inline]
       btrfs_get_tree_subvol fs/btrfs/super.c:2087 [inline]
       btrfs_get_tree+0x1061/0x1930 fs/btrfs/super.c:2121
       vfs_get_tree+0x92/0x2a0 fs/super.c:1754
       fc_mount fs/namespace.c:1193 [inline]
       do_new_mount_fc fs/namespace.c:3763 [inline]
       do_new_mount+0x341/0xd30 fs/namespace.c:3839
       do_mount fs/namespace.c:4172 [inline]
       __do_sys_mount fs/namespace.c:4361 [inline]
       __se_sys_mount+0x31d/0x420 fs/namespace.c:4338
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #2 (btrfs_trans_num_writers){++++}-{0:0}:
       __lock_release kernel/locking/lockdep.c:5574 [inline]
       lock_release+0x199/0x3d0 kernel/locking/lockdep.c:5889
       percpu_up_read include/linux/percpu-rwsem.h:112 [inline]
       __sb_end_write include/linux/fs/super.h:14 [inline]
       sb_end_intwrite+0x26/0x1c0 include/linux/fs/super.h:101
       __btrfs_end_transaction+0x248/0x640 fs/btrfs/transaction.c:1085
       btrfs_dirty_inode+0x14c/0x190 fs/btrfs/inode.c:6457
       file_update_time_flags+0x2d5/0x4b0 fs/inode.c:2426
       btrfs_page_mkwrite+0x5df/0x1b10 fs/btrfs/file.c:1914
       do_page_mkwrite+0x150/0x310 mm/memory.c:3589
       wp_page_shared mm/memory.c:3990 [inline]
       do_wp_page+0x203b/0x49d0 mm/memory.c:4209
       handle_pte_fault mm/memory.c:6333 [inline]
       __handle_mm_fault mm/memory.c:6455 [inline]
       handle_mm_fault+0x9f5/0x13c0 mm/memory.c:6624
       do_user_addr_fault+0xa73/0x1340 arch/x86/mm/fault.c:1334
       handle_page_fault arch/x86/mm/fault.c:1474 [inline]
       exc_page_fault+0x6a/0xc0 arch/x86/mm/fault.c:1527
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:618

-> #1 (sb_pagefaults#2){.+.+}-{0:0}:
       percpu_down_read_internal include/linux/percpu-rwsem.h:53 [inline]
       percpu_down_read_freezable include/linux/percpu-rwsem.h:83 [inline]
       __sb_start_write include/linux/fs/super.h:19 [inline]
       sb_start_pagefault include/linux/fs/super.h:159 [inline]
       btrfs_page_mkwrite+0x329/0x1b10 fs/btrfs/file.c:1873
       do_page_mkwrite+0x150/0x310 mm/memory.c:3589
       do_shared_fault mm/memory.c:5875 [inline]
       do_fault mm/memory.c:5937 [inline]
       do_pte_missing+0x711/0x29e0 mm/memory.c:4477
       handle_pte_fault mm/memory.c:6317 [inline]
       __handle_mm_fault mm/memory.c:6455 [inline]
       handle_mm_fault+0xd0a/0x13c0 mm/memory.c:6624
       do_user_addr_fault+0x75b/0x1340 arch/x86/mm/fault.c:1385
       handle_page_fault arch/x86/mm/fault.c:1474 [inline]
       exc_page_fault+0x6a/0xc0 arch/x86/mm/fault.c:1527
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:618

-> #0 (&mm->mmap_lock){++++}-{4:4}:
       check_prev_add kernel/locking/lockdep.c:3165 [inline]
       check_prevs_add kernel/locking/lockdep.c:3284 [inline]
       validate_chain kernel/locking/lockdep.c:3908 [inline]
       __lock_acquire+0x15a5/0x2cf0 kernel/locking/lockdep.c:5237
       lock_acquire+0xf0/0x2e0 kernel/locking/lockdep.c:5868
       down_read_killable+0xa4/0x220 kernel/locking/rwsem.c:1560
       mmap_read_lock_killable+0x1d/0x70 include/linux/mmap_lock.h:601
       get_mmap_lock_carefully mm/mmap_lock.c:450 [inline]
       lock_mm_and_find_vma+0x2d7/0x340 mm/mmap_lock.c:501
       do_user_addr_fault+0x330/0x1340 arch/x86/mm/fault.c:1357
       handle_page_fault arch/x86/mm/fault.c:1474 [inline]
       exc_page_fault+0x6a/0xc0 arch/x86/mm/fault.c:1527
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:618
       user_access_begin arch/x86/include/asm/uaccess.h:-1 [inline]
       filldir+0x29b/0x690 fs/readdir.c:290
       dir_emit_dot include/linux/fs.h:3570 [inline]
       dir_emit_dots include/linux/fs.h:3581 [inline]
       offset_readdir+0x1aa/0x530 fs/libfs.c:562
       iterate_dir+0x3a5/0x580 fs/readdir.c:108
       __do_sys_getdents fs/readdir.c:327 [inline]
       __se_sys_getdents+0xf1/0x270 fs/readdir.c:312
       do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
       do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

Chain exists of:
  &mm->mmap_lock --> &fs_devs->device_list_mutex --> &type->i_mutex_dir_key#5

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(&type->i_mutex_dir_key#5);
                               lock(&fs_devs->device_list_mutex);
                               lock(&type->i_mutex_dir_key#5);
  rlock(&mm->mmap_lock);

 *** DEADLOCK ***

2 locks held by syz.4.1326/16680:
 #0: ffff88803c892f28 (&f->f_pos_lock){+.+.}-{4:4}, at: fdget_pos+0x252/0x320 fs/file.c:1261
 #1: ffff888060d0a498 (&type->i_mutex_dir_key#5){++++}-{4:4}, at: iterate_dir+0x29e/0x580 fs/readdir.c:101

stack backtrace:
CPU: 0 UID: 0 PID: 16680 Comm: syz.4.1326 Not tainted syzkaller #0 PREEMPT_{RT,(full)} 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/18/2026
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
 print_circular_bug+0x2e1/0x300 kernel/locking/lockdep.c:2043
 check_noncircular+0x12e/0x150 kernel/locking/lockdep.c:2175
 check_prev_add kernel/locking/lockdep.c:3165 [inline]
 check_prevs_add kernel/locking/lockdep.c:3284 [inline]
 validate_chain kernel/locking/lockdep.c:3908 [inline]
 __lock_acquire+0x15a5/0x2cf0 kernel/locking/lockdep.c:5237
 lock_acquire+0xf0/0x2e0 kernel/locking/lockdep.c:5868
 down_read_killable+0xa4/0x220 kernel/locking/rwsem.c:1560
 mmap_read_lock_killable+0x1d/0x70 include/linux/mmap_lock.h:601
 get_mmap_lock_carefully mm/mmap_lock.c:450 [inline]
 lock_mm_and_find_vma+0x2d7/0x340 mm/mmap_lock.c:501
 do_user_addr_fault+0x330/0x1340 arch/x86/mm/fault.c:1357
 handle_page_fault arch/x86/mm/fault.c:1474 [inline]
 exc_page_fault+0x6a/0xc0 arch/x86/mm/fault.c:1527
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:618
RIP: 0010:filldir+0x29b/0x690 fs/readdir.c:294
Code: 86 ff 4c 89 ff 4c 89 e6 e8 c2 96 86 ff 4d 39 e7 0f 82 7c 02 00 00 49 39 ef 0f 87 73 02 00 00 0f 01 cb 0f ae e8 48 8b 44 24 50 <49> 89 44 24 08 48 8b 4c 24 08 48 8b 44 24 58 48 89 01 48 8b 04 24
RSP: 0018:ffffc90003ed7c70 EFLAGS: 00050287
RAX: 0000000000000000 RBX: ffffc90003ed7e38 RCX: ffff8880308f5b80
RDX: 0000000000000000 RSI: 0000200000001fc0 RDI: 0000200000001fd8
RBP: 00007ffffffff000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000100 R11: ffffffff823deb50 R12: 0000200000001fc0
R13: ffffffff8b5dc340 R14: 0000000000000001 R15: 0000200000001fd8
 dir_emit_dot include/linux/fs.h:3570 [inline]
 dir_emit_dots include/linux/fs.h:3581 [inline]
 offset_readdir+0x1aa/0x530 fs/libfs.c:562
 iterate_dir+0x3a5/0x580 fs/readdir.c:108
 __do_sys_getdents fs/readdir.c:327 [inline]
 __se_sys_getdents+0xf1/0x270 fs/readdir.c:312
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f0fda72c819
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 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 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f0fd897e028 EFLAGS: 00000246 ORIG_RAX: 000000000000004e
RAX: ffffffffffffffda RBX: 00007f0fda9a5fa0 RCX: 00007f0fda72c819
RDX: 00000000000000b8 RSI: 0000200000001fc0 RDI: 0000000000000005
RBP: 00007f0fda7c2c91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f0fda9a6038 R14: 00007f0fda9a5fa0 R15: 00007ffe935bc848
 </TASK>
----------------
Code disassembly (best guess):
   0:	86 ff                	xchg   %bh,%bh
   2:	4c 89 ff             	mov    %r15,%rdi
   5:	4c 89 e6             	mov    %r12,%rsi
   8:	e8 c2 96 86 ff       	call   0xff8696cf
   d:	4d 39 e7             	cmp    %r12,%r15
  10:	0f 82 7c 02 00 00    	jb     0x292
  16:	49 39 ef             	cmp    %rbp,%r15
  19:	0f 87 73 02 00 00    	ja     0x292
  1f:	0f 01 cb             	stac
  22:	0f ae e8             	lfence
  25:	48 8b 44 24 50       	mov    0x50(%rsp),%rax
* 2a:	49 89 44 24 08       	mov    %rax,0x8(%r12) <-- trapping instruction
  2f:	48 8b 4c 24 08       	mov    0x8(%rsp),%rcx
  34:	48 8b 44 24 58       	mov    0x58(%rsp),%rax
  39:	48 89 01             	mov    %rax,(%rcx)
  3c:	48 8b 04 24          	mov    (%rsp),%rax

Crashes (19):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/04/09 15:39 upstream 7f87a5ea75f0 38c8e246 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in iterate_dir
2026/04/09 14:24 upstream 7f87a5ea75f0 38c8e246 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in iterate_dir
2026/04/08 19:55 upstream 3036cd0d3328 d9b7f621 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in iterate_dir
2026/04/07 21:51 upstream 3036cd0d3328 628666c6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in iterate_dir
2026/04/05 09:55 upstream 3aae9383f42f 4440e7c2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in iterate_dir
2026/04/04 18:27 upstream 7ca6d1cfec80 4440e7c2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in iterate_dir
2026/04/03 10:34 upstream 5619b098e2fb 4440e7c2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in iterate_dir
2026/04/03 04:18 upstream 5619b098e2fb 4440e7c2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in iterate_dir
2026/01/02 12:20 upstream b69053dd3ffb d6526ea3 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in iterate_dir
2025/12/21 03:49 upstream d8ba32c5a460 d6526ea3 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in iterate_dir
2025/11/23 08:01 upstream 89edd36fd801 4fb8ef37 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in iterate_dir
2025/10/29 05:20 upstream 8eefed8f65cc fd2207e7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in iterate_dir
2025/10/16 07:24 upstream 7ea30958b305 19568248 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in iterate_dir
2025/10/13 21:42 upstream 3a8660878839 b6605ba8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in iterate_dir
2025/09/22 18:52 upstream 07e27ad16399 0ac7291c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in iterate_dir
2025/09/19 18:36 upstream 097a6c336d00 67c37560 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in iterate_dir
2025/09/16 18:34 upstream 46a51f4f5eda e2beed91 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in iterate_dir
2025/09/15 23:32 upstream f83ec76bf285 e2beed91 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in iterate_dir
2025/09/10 06:35 upstream 9dd1835ecda5 fdeaa69b .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in iterate_dir
* Struck through repros no longer work on HEAD.