syzbot


possible deadlock in iterate_dir (2)

Status: auto-obsoleted due to no activity on 2024/03/08 13:21
Reported-by: syzbot+ae07d55f2021d33f9cb4@syzkaller.appspotmail.com
First crash: 450d, last: 358d
Similar bugs (7)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 possible deadlock in iterate_dir (3) origin:upstream C error 6 44d 232d 0/3 upstream: reported C repro on 2024/04/03 07:56
linux-6.1 possible deadlock in iterate_dir (2) 2 210d 236d 0/3 auto-obsoleted due to no activity on 2024/08/02 17:42
linux-6.1 possible deadlock in iterate_dir 2 490d 496d 0/3 auto-obsoleted due to no activity on 2023/10/27 20:39
linux-4.14 possible deadlock in iterate_dir ubifs C 11375 625d 1620d 0/1 upstream: reported C repro on 2020/06/15 06:16
linux-4.19 possible deadlock in iterate_dir 1 1791d 1791d 0/1 auto-closed as invalid on 2020/04/24 15:06
upstream possible deadlock in iterate_dir reiserfs 23 455d 698d 0/28 auto-obsoleted due to no activity on 2023/12/01 22:38
linux-5.15 possible deadlock in iterate_dir 1 605d 605d 0/3 auto-obsoleted due to no activity on 2023/07/25 13:55

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
5.15.140-syzkaller #0 Not tainted
------------------------------------------------------
udevd/8612 is trying to acquire lock:
ffff0000dcb38118 (&mm->mmap_lock){++++}-{3:3}, at: __might_fault+0xa0/0x128 mm/memory.c:5323

but task is already holding lock:
ffff0000c08888b0 (&type->i_mutex_dir_key#2){++++}-{3:3}, at: iterate_dir+0x108/0x4e4 fs/readdir.c:55

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #4 (&type->i_mutex_dir_key#2){++++}-{3:3}:
       down_read+0xc0/0x398 kernel/locking/rwsem.c:1488
       inode_lock_shared include/linux/fs.h:797 [inline]
       lookup_slow+0x50/0x84 fs/namei.c:1675
       walk_component+0x394/0x4cc fs/namei.c:1972
       lookup_last fs/namei.c:2427 [inline]
       path_lookupat+0x13c/0x3d0 fs/namei.c:2451
       filename_lookup+0x1c4/0x4c8 fs/namei.c:2480
       kern_path+0x4c/0x194 fs/namei.c:2570
       lookup_bdev+0xc0/0x25c block/bdev.c:979
       device_matched fs/btrfs/volumes.c:563 [inline]
       btrfs_free_stale_devices+0x61c/0x9ec fs/btrfs/volumes.c:608
       btrfs_scan_one_device+0x438/0x5f8 fs/btrfs/volumes.c:1448
       btrfs_control_ioctl+0xe0/0x248 fs/btrfs/super.c:2455
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:874 [inline]
       __se_sys_ioctl fs/ioctl.c:860 [inline]
       __arm64_sys_ioctl+0x14c/0x1c8 fs/ioctl.c:860
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
       el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608
       el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
       el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #3 (&fs_devs->device_list_mutex){+.+.}-{3:3}:
       __mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
       btrfs_run_dev_stats+0xe4/0xe24 fs/btrfs/volumes.c:7930
       commit_cowonly_roots+0x17c/0x808 fs/btrfs/transaction.c:1290
       btrfs_commit_transaction+0xef4/0x30f0 fs/btrfs/transaction.c:2392
       btrfs_commit_super+0xb4/0xd0 fs/btrfs/disk-io.c:4326
       close_ctree+0x378/0x860 fs/btrfs/disk-io.c:4438
       btrfs_put_super+0x40/0x50 fs/btrfs/super.c:340
       generic_shutdown_super+0x130/0x29c fs/super.c:475
       kill_anon_super+0x4c/0x74 fs/super.c:1076
       btrfs_kill_super+0x40/0x58 fs/btrfs/super.c:2391
       deactivate_locked_super+0xb8/0x13c fs/super.c:335
       deactivate_super+0x108/0x128 fs/super.c:366
       cleanup_mnt+0x3c0/0x474 fs/namespace.c:1143
       __cleanup_mnt+0x20/0x30 fs/namespace.c:1150
       task_work_run+0x130/0x1e4 kernel/task_work.c:164
       tracehook_notify_resume include/linux/tracehook.h:189 [inline]
       do_notify_resume+0x262c/0x32b8 arch/arm64/kernel/signal.c:946
       prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:133 [inline]
       exit_to_user_mode arch/arm64/kernel/entry-common.c:138 [inline]
       el0_svc+0xfc/0x1f0 arch/arm64/kernel/entry-common.c:609
       el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
       el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #2 (&fs_info->tree_log_mutex){+.+.}-{3:3}:
       __lock_release kernel/locking/lockdep.c:5338 [inline]
       lock_release+0x340/0xa1c kernel/locking/lockdep.c:5642
       __mutex_unlock_slowpath+0xe0/0x6d4 kernel/locking/mutex.c:851
       mutex_unlock+0x8c/0xe0 kernel/locking/mutex.c:536
       btrfs_commit_transaction+0x1650/0x30f0 fs/btrfs/transaction.c:2439
       btrfs_commit_super+0xb4/0xd0 fs/btrfs/disk-io.c:4326
       close_ctree+0x378/0x860 fs/btrfs/disk-io.c:4438
       btrfs_put_super+0x40/0x50 fs/btrfs/super.c:340
       generic_shutdown_super+0x130/0x29c fs/super.c:475
       kill_anon_super+0x4c/0x74 fs/super.c:1076
       btrfs_kill_super+0x40/0x58 fs/btrfs/super.c:2391
       deactivate_locked_super+0xb8/0x13c fs/super.c:335
       deactivate_super+0x108/0x128 fs/super.c:366
       cleanup_mnt+0x3c0/0x474 fs/namespace.c:1143
       __cleanup_mnt+0x20/0x30 fs/namespace.c:1150
       task_work_run+0x130/0x1e4 kernel/task_work.c:164
       tracehook_notify_resume include/linux/tracehook.h:189 [inline]
       do_notify_resume+0x262c/0x32b8 arch/arm64/kernel/signal.c:946
       prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:133 [inline]
       exit_to_user_mode arch/arm64/kernel/entry-common.c:138 [inline]
       el0_svc+0xfc/0x1f0 arch/arm64/kernel/entry-common.c:609
       el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
       el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #1 (sb_internal#2){.+.+}-{0:0}:
       percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
       __sb_start_write include/linux/fs.h:1742 [inline]
       sb_start_intwrite include/linux/fs.h:1859 [inline]
       start_transaction+0x644/0x1480 fs/btrfs/transaction.c:678
       btrfs_join_transaction+0x30/0x40 fs/btrfs/transaction.c:791
       btrfs_dirty_inode+0xb4/0x1c0 fs/btrfs/inode.c:6329
       btrfs_update_time+0x248/0x270 fs/btrfs/inode.c:6371
       inode_update_time fs/inode.c:1829 [inline]
       touch_atime+0x434/0xa4c fs/inode.c:1902
       file_accessed include/linux/fs.h:2447 [inline]
       btrfs_file_mmap+0xb0/0x11c fs/btrfs/file.c:2424
       call_mmap include/linux/fs.h:2108 [inline]
       mmap_region+0xcb4/0x12f0 mm/mmap.c:1791
       do_mmap+0x6c0/0xcec mm/mmap.c:1575
       vm_mmap_pgoff+0x1a4/0x2b4 mm/util.c:551
       ksys_mmap_pgoff+0x458/0x668 mm/mmap.c:1624
       __do_sys_mmap arch/arm64/kernel/sys.c:28 [inline]
       __se_sys_mmap arch/arm64/kernel/sys.c:21 [inline]
       __arm64_sys_mmap+0xf8/0x110 arch/arm64/kernel/sys.c:21
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
       el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608
       el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
       el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #0 (&mm->mmap_lock){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3053 [inline]
       check_prevs_add kernel/locking/lockdep.c:3172 [inline]
       validate_chain kernel/locking/lockdep.c:3787 [inline]
       __lock_acquire+0x32cc/0x7620 kernel/locking/lockdep.c:5011
       lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5622
       __might_fault+0xc8/0x128 mm/memory.c:5324
       filldir64+0x2bc/0x9e4 fs/readdir.c:335
       dir_emit_dot include/linux/fs.h:3607 [inline]
       dir_emit_dots include/linux/fs.h:3618 [inline]
       dcache_readdir+0x134/0x678 fs/libfs.c:196
       iterate_dir+0x1f4/0x4e4
       __do_sys_getdents64 fs/readdir.c:369 [inline]
       __se_sys_getdents64 fs/readdir.c:354 [inline]
       __arm64_sys_getdents64+0x1c4/0x4c4 fs/readdir.c:354
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
       el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608
       el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
       el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

other info that might help us debug this:

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

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

2 locks held by udevd/8612:
 #0: ffff0000d5e16ff0 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x128/0x170 fs/file.c:1088
 #1: ffff0000c08888b0 (&type->i_mutex_dir_key#2){++++}-{3:3}, at: iterate_dir+0x108/0x4e4 fs/readdir.c:55

stack backtrace:
CPU: 0 PID: 8612 Comm: udevd Not tainted 5.15.140-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023
Call trace:
 dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
 dump_stack+0x1c/0x58 lib/dump_stack.c:113
 print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2011
 check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2133
 check_prev_add kernel/locking/lockdep.c:3053 [inline]
 check_prevs_add kernel/locking/lockdep.c:3172 [inline]
 validate_chain kernel/locking/lockdep.c:3787 [inline]
 __lock_acquire+0x32cc/0x7620 kernel/locking/lockdep.c:5011
 lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5622
 __might_fault+0xc8/0x128 mm/memory.c:5324
 filldir64+0x2bc/0x9e4 fs/readdir.c:335
 dir_emit_dot include/linux/fs.h:3607 [inline]
 dir_emit_dots include/linux/fs.h:3618 [inline]
 dcache_readdir+0x134/0x678 fs/libfs.c:196
 iterate_dir+0x1f4/0x4e4
 __do_sys_getdents64 fs/readdir.c:369 [inline]
 __se_sys_getdents64 fs/readdir.c:354 [inline]
 __arm64_sys_getdents64+0x1c4/0x4c4 fs/readdir.c:354
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
 el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608
 el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/11/29 13:20 linux-5.15.y a78d278e01b1 6e78f9ce .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in iterate_dir
2023/08/28 16:55 linux-5.15.y 5ddfe5cc8716 7ba13a15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in iterate_dir
* Struck through repros no longer work on HEAD.