[v6.1] possible deadlock in lookup_slow (2)

2 views
Skip to first unread message

syzbot

unread,
May 16, 2025, 1:47:34 PM5/16/25
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 02b72ccb5f9d Linux 6.1.138
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=169396f4580000
kernel config: https://syzkaller.appspot.com/x/.config?x=bf58f23078f7c65f
dashboard link: https://syzkaller.appspot.com/bug?extid=8dab26395833f6231fa9
compiler: Debian clang version 20.1.2 (++20250402124445+58df0ef89dd6-1~exp1~20250402004600.97), Debian LLD 20.1.2
userspace arch: arm64

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/5d1b23281780/disk-02b72ccb.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/b8a155658d46/vmlinux-02b72ccb.xz
kernel image: https://storage.googleapis.com/syzbot-assets/dd3acfbc6217/Image-02b72ccb.gz.xz

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

loop1: detected capacity change from 0 to 32768
======================================================
WARNING: possible circular locking dependency detected
6.1.138-syzkaller #0 Not tainted
------------------------------------------------------
syz.1.715/7463 is trying to acquire lock:
ffff0000c09208e0 (&type->i_mutex_dir_key#2){++++}-{3:3}, at: inode_lock_shared include/linux/fs.h:768 [inline]
ffff0000c09208e0 (&type->i_mutex_dir_key#2){++++}-{3:3}, at: lookup_slow+0x4c/0x80 fs/namei.c:1706

but task is already holding lock:
ffff0000cb2f00e0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: device_list_add+0x7cc/0x1be0 fs/btrfs/volumes.c:860

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #5 (&fs_devs->device_list_mutex){+.+.}-{3:3}:
__mutex_lock_common+0x190/0x1f38 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
btrfs_run_dev_stats+0xf0/0xd00 fs/btrfs/volumes.c:8058
commit_cowonly_roots+0x16c/0x714 fs/btrfs/transaction.c:1297
btrfs_commit_transaction+0x10bc/0x29f0 fs/btrfs/transaction.c:2427
btrfs_sync_fs+0x530/0xa30 fs/btrfs/super.c:1535
sync_filesystem+0x1a0/0x218 fs/sync.c:66
generic_shutdown_super+0x70/0x324 fs/super.c:474
kill_anon_super+0x4c/0x80 fs/super.c:1128
btrfs_kill_super+0x40/0x58 fs/btrfs/super.c:2448
deactivate_locked_super+0xac/0x124 fs/super.c:332
deactivate_super+0xe8/0x108 fs/super.c:363
cleanup_mnt+0x37c/0x404 fs/namespace.c:1186
__cleanup_mnt+0x20/0x30 fs/namespace.c:1193
task_work_run+0x1ec/0x270 kernel/task_work.c:203
resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
do_notify_resume+0x1f70/0x2b0c arch/arm64/kernel/signal.c:1137
prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:137 [inline]
exit_to_user_mode arch/arm64/kernel/entry-common.c:142 [inline]
el0_svc+0x98/0x138 arch/arm64/kernel/entry-common.c:638
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

-> #4 (&fs_info->reloc_mutex){+.+.}-{3:3}:
__mutex_lock_common+0x190/0x1f38 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
btrfs_record_root_in_trans fs/btrfs/transaction.c:488 [inline]
start_transaction+0x434/0x104c fs/btrfs/transaction.c:730
btrfs_start_transaction+0x34/0x44 fs/btrfs/transaction.c:766
btrfs_create_common+0x13c/0x224 fs/btrfs/inode.c:6782
btrfs_create+0x104/0x128 fs/btrfs/inode.c:6828
lookup_open fs/namei.c:3482 [inline]
open_last_lookups fs/namei.c:3550 [inline]
path_openat+0x112c/0x2680 fs/namei.c:3780
do_filp_open+0x174/0x344 fs/namei.c:3810
do_sys_openat2+0x128/0x3d8 fs/open.c:1318
do_sys_open fs/open.c:1334 [inline]
__do_sys_openat fs/open.c:1350 [inline]
__se_sys_openat fs/open.c:1345 [inline]
__arm64_sys_openat+0x120/0x154 fs/open.c:1345
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2bc arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140
do_el0_svc+0x58/0x13c arch/arm64/kernel/syscall.c:204
el0_svc+0x58/0x138 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

-> #3 (btrfs_trans_num_extwriters){++++}-{0:0}:
join_transaction+0x180/0xb6c fs/btrfs/transaction.c:303
start_transaction+0x854/0x104c fs/btrfs/transaction.c:667
btrfs_start_transaction+0x34/0x44 fs/btrfs/transaction.c:766
btrfs_create_common+0x13c/0x224 fs/btrfs/inode.c:6782
btrfs_create+0x104/0x128 fs/btrfs/inode.c:6828
lookup_open fs/namei.c:3482 [inline]
open_last_lookups fs/namei.c:3550 [inline]
path_openat+0x112c/0x2680 fs/namei.c:3780
do_filp_open+0x174/0x344 fs/namei.c:3810
do_sys_openat2+0x128/0x3d8 fs/open.c:1318
do_sys_open fs/open.c:1334 [inline]
__do_sys_openat fs/open.c:1350 [inline]
__se_sys_openat fs/open.c:1345 [inline]
__arm64_sys_openat+0x120/0x154 fs/open.c:1345
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2bc arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140
do_el0_svc+0x58/0x13c arch/arm64/kernel/syscall.c:204
el0_svc+0x58/0x138 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

-> #2 (btrfs_trans_num_writers){++++}-{0:0}:
__lock_release kernel/locking/lockdep.c:5376 [inline]
lock_release+0x308/0x910 kernel/locking/lockdep.c:5682
percpu_up_read include/linux/percpu-rwsem.h:99 [inline]
__sb_end_write include/linux/fs.h:1886 [inline]
sb_end_intwrite+0x54/0x360 include/linux/fs.h:1942
__btrfs_end_transaction+0x1f4/0x5fc fs/btrfs/transaction.c:1017
btrfs_end_transaction+0x24/0x34 fs/btrfs/transaction.c:1051
btrfs_dirty_inode+0x16c/0x1c0 fs/btrfs/inode.c:6288
btrfs_update_time+0x170/0x18c fs/btrfs/inode.c:6316
inode_update_time fs/inode.c:1958 [inline]
touch_atime+0x364/0x7d0 fs/inode.c:2031
file_accessed include/linux/fs.h:2600 [inline]
btrfs_file_mmap+0xb0/0x11c fs/btrfs/file.c:2053
call_mmap include/linux/fs.h:2270 [inline]
mmap_file+0x6c/0xc8 mm/util.c:1109
__mmap_region mm/mmap.c:2760 [inline]
mmap_region+0xcc8/0x1860 mm/mmap.c:2904
do_mmap+0x978/0x10dc mm/mmap.c:1424
vm_mmap_pgoff+0x184/0x284 mm/util.c:520
ksys_mmap_pgoff+0x3b8/0x5a0 mm/mmap.c:1470
__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/0x2bc arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140
do_el0_svc+0x58/0x13c arch/arm64/kernel/syscall.c:204
el0_svc+0x58/0x138 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 (&mm->mmap_lock){++++}-{3:3}:
__might_fault+0xc4/0x124 mm/memory.c:5852
filldir64+0x2cc/0x8fc fs/readdir.c:335
dir_emit_dot include/linux/fs.h:3699 [inline]
dir_emit_dots include/linux/fs.h:3710 [inline]
dcache_readdir+0x140/0x62c fs/libfs.c:197
iterate_dir+0x1f0/0x4cc fs/readdir.c:-1
__do_sys_getdents64 fs/readdir.c:369 [inline]
__se_sys_getdents64 fs/readdir.c:354 [inline]
__arm64_sys_getdents64+0x11c/0x318 fs/readdir.c:354
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2bc arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140
do_el0_svc+0x58/0x13c arch/arm64/kernel/syscall.c:204
el0_svc+0x58/0x138 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 (&type->i_mutex_dir_key#2){++++}-{3:3}:
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+0x293c/0x6544 kernel/locking/lockdep.c:5049
lock_acquire+0x20c/0x644 kernel/locking/lockdep.c:5662
down_read+0x64/0x304 kernel/locking/rwsem.c:1520
inode_lock_shared include/linux/fs.h:768 [inline]
lookup_slow+0x4c/0x80 fs/namei.c:1706
walk_component+0x270/0x364 fs/namei.c:1998
lookup_last fs/namei.c:2455 [inline]
path_lookupat+0x13c/0x3d0 fs/namei.c:2479
filename_lookup+0x190/0x42c fs/namei.c:2508
kern_path+0x48/0x6c fs/namei.c:2606
is_same_device fs/btrfs/volumes.c:695 [inline]
device_list_add+0x1208/0x1be0 fs/btrfs/volumes.c:928
btrfs_scan_one_device+0x364/0x570 fs/btrfs/volumes.c:1461
btrfs_mount_root+0x404/0x780 fs/btrfs/super.c:1796
legacy_get_tree+0xd4/0x16c fs/fs_context.c:632
vfs_get_tree+0x90/0x274 fs/super.c:1573
fc_mount fs/namespace.c:1043 [inline]
vfs_kern_mount+0xdc/0x178 fs/namespace.c:1073
btrfs_mount+0x2a0/0x8dc fs/btrfs/super.c:1894
legacy_get_tree+0xd4/0x16c fs/fs_context.c:632
vfs_get_tree+0x90/0x274 fs/super.c:1573
do_new_mount+0x228/0x810 fs/namespace.c:3057
path_mount+0x5b4/0xe78 fs/namespace.c:3387
do_mount fs/namespace.c:3400 [inline]
__do_sys_mount fs/namespace.c:3608 [inline]
__se_sys_mount fs/namespace.c:3585 [inline]
__arm64_sys_mount+0x49c/0x584 fs/namespace.c:3585
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2bc arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140
do_el0_svc+0x58/0x13c arch/arm64/kernel/syscall.c:204
el0_svc+0x58/0x138 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:
&type->i_mutex_dir_key#2 --> &fs_info->reloc_mutex --> &fs_devs->device_list_mutex

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&fs_devs->device_list_mutex);
lock(&fs_info->reloc_mutex);
lock(&fs_devs->device_list_mutex);
lock(&type->i_mutex_dir_key#2);

*** DEADLOCK ***

2 locks held by syz.1.715/7463:
#0: ffff8000157832a8 (uuid_mutex){+.+.}-{3:3}, at: btrfs_mount_root+0x1f4/0x780 fs/btrfs/super.c:1789
#1: ffff0000cb2f00e0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: device_list_add+0x7cc/0x1be0 fs/btrfs/volumes.c:860

stack backtrace:
CPU: 0 PID: 7463 Comm: syz.1.715 Not tainted 6.1.138-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Call trace:
dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
__dump_stack+0x30/0x40 lib/dump_stack.c:88
dump_stack_lvl+0xf8/0x160 lib/dump_stack.c:106
dump_stack+0x1c/0x5c lib/dump_stack.c:113
print_circular_bug+0x148/0x1b0 kernel/locking/lockdep.c:2048
check_noncircular+0x240/0x2d4 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+0x293c/0x6544 kernel/locking/lockdep.c:5049
lock_acquire+0x20c/0x644 kernel/locking/lockdep.c:5662
down_read+0x64/0x304 kernel/locking/rwsem.c:1520
inode_lock_shared include/linux/fs.h:768 [inline]
lookup_slow+0x4c/0x80 fs/namei.c:1706
walk_component+0x270/0x364 fs/namei.c:1998
lookup_last fs/namei.c:2455 [inline]
path_lookupat+0x13c/0x3d0 fs/namei.c:2479
filename_lookup+0x190/0x42c fs/namei.c:2508
kern_path+0x48/0x6c fs/namei.c:2606
is_same_device fs/btrfs/volumes.c:695 [inline]
device_list_add+0x1208/0x1be0 fs/btrfs/volumes.c:928
btrfs_scan_one_device+0x364/0x570 fs/btrfs/volumes.c:1461
btrfs_mount_root+0x404/0x780 fs/btrfs/super.c:1796
legacy_get_tree+0xd4/0x16c fs/fs_context.c:632
vfs_get_tree+0x90/0x274 fs/super.c:1573
fc_mount fs/namespace.c:1043 [inline]
vfs_kern_mount+0xdc/0x178 fs/namespace.c:1073
btrfs_mount+0x2a0/0x8dc fs/btrfs/super.c:1894
legacy_get_tree+0xd4/0x16c fs/fs_context.c:632
vfs_get_tree+0x90/0x274 fs/super.c:1573
do_new_mount+0x228/0x810 fs/namespace.c:3057
path_mount+0x5b4/0xe78 fs/namespace.c:3387
do_mount fs/namespace.c:3400 [inline]
__do_sys_mount fs/namespace.c:3608 [inline]
__se_sys_mount fs/namespace.c:3585 [inline]
__arm64_sys_mount+0x49c/0x584 fs/namespace.c:3585
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2bc arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140
do_el0_svc+0x58/0x13c arch/arm64/kernel/syscall.c:204
el0_svc+0x58/0x138 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
BTRFS info (device loop1): first mount of filesystem c9fe44da-de57-406a-8241-57ec7d4412cf
BTRFS info (device loop1): using crc32c (crc32c-generic) checksum algorithm
BTRFS info (device loop1): metadata ratio 4
BTRFS info (device loop1): setting incompat feature flag for COMPRESS_LZO (0x8)
BTRFS info (device loop1): force lzo compression, level 0
BTRFS warning (device loop1): 'usebackuproot' is deprecated, use 'rescue=usebackuproot' instead
BTRFS info (device loop1): trying to use backup root at mount time
BTRFS info (device loop1): doing ref verification
BTRFS info (device loop1): enabling ssd optimizations
BTRFS info (device loop1): using spread ssd allocation scheme
BTRFS info (device loop1): using free space tree
BTRFS warning (device loop1): couldn't read tree root
BTRFS warning (device loop1): try to load backup roots slot 1
BTRFS warning (device loop1): couldn't read tree root
BTRFS warning (device loop1): try to load backup roots slot 2
BTRFS error (device loop1): parent transid verify failed on logical 5255168 mirror 1 wanted 5 found 7
BTRFS warning (device loop1): couldn't read tree root
BTRFS warning (device loop1): try to load backup roots slot 3
BTRFS info (device loop1): rebuilding free space tree
BTRFS info (device loop1): checking UUID tree


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