syzbot


possible deadlock in btrfs_join_transaction

Status: upstream: reported on 2024/01/20 21:24
Reported-by: syzbot+41d447453faf9e956c83@syzkaller.appspotmail.com
First crash: 263d, last: 19d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in btrfs_join_transaction btrfs C 2 681d 686d 0/28 auto-obsoleted due to no activity on 2023/03/29 11:54

Sample crash report:
BTRFS info (device loop1): using free space tree
BTRFS info (device loop1): has skinny extents
BTRFS info (device loop1): enabling ssd optimizations
======================================================
WARNING: possible circular locking dependency detected
5.15.167-syzkaller #0 Not tainted
------------------------------------------------------
syz.1.421/5864 is trying to acquire lock:
ffff0000d57ec650 (sb_internal#3){.+.+}-{0:0}, at: btrfs_join_transaction+0x30/0x40 fs/btrfs/transaction.c:791

but task is already holding lock:
ffff0000d8eb62d8 (&mm->mmap_lock){++++}-{3:3}, at: mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline]
ffff0000d8eb62d8 (&mm->mmap_lock){++++}-{3:3}, at: vm_mmap_pgoff+0x15c/0x2b4 mm/util.c:549

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #5 (&mm->mmap_lock){++++}-{3:3}:
       __might_fault+0xc8/0x128 mm/memory.c:5327
       filldir64+0x2bc/0x9e4 fs/readdir.c:335
       dir_emit_dot include/linux/fs.h:3683 [inline]
       hfs_readdir+0x328/0xc68 fs/hfs/dir.c:72
       iterate_dir+0x1f4/0x4ec
       __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

-> #4 (&tree->tree_lock#2){+.+.}-{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
       hfs_find_init+0x148/0x1c8
       hfs_lookup+0x124/0x2ac fs/hfs/dir.c:28
       __lookup_slow+0x250/0x388 fs/namei.c:1663
       lookup_slow+0x60/0x84 fs/namei.c:1680
       walk_component+0x394/0x4cc fs/namei.c:1976
       lookup_last fs/namei.c:2431 [inline]
       path_lookupat+0x13c/0x3d0 fs/namei.c:2455
       filename_lookup+0x1c4/0x4c8 fs/namei.c:2484
       user_path_at_empty+0x5c/0x1a4 fs/namei.c:2883
       user_path_at include/linux/namei.h:57 [inline]
       __do_sys_fspick fs/fsopen.c:181 [inline]
       __se_sys_fspick fs/fsopen.c:158 [inline]
       __arm64_sys_fspick+0x19c/0x44c fs/fsopen.c:158
       __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 (&type->i_mutex_dir_key#19){++++}-{3:3}:
       down_read+0xc0/0x398 kernel/locking/rwsem.c:1498
       inode_lock_shared include/linux/fs.h:799 [inline]
       lookup_slow+0x50/0x84 fs/namei.c:1679
       walk_component+0x394/0x4cc fs/namei.c:1976
       lookup_last fs/namei.c:2431 [inline]
       path_lookupat+0x13c/0x3d0 fs/namei.c:2455
       filename_lookup+0x1c4/0x4c8 fs/namei.c:2484
       kern_path+0x4c/0x194 fs/namei.c:2582
       lookup_bdev+0xc0/0x25c block/bdev.c:979
       device_matched fs/btrfs/volumes.c:568 [inline]
       btrfs_free_stale_devices+0x658/0x9ec fs/btrfs/volumes.c:608
       btrfs_forget_devices+0x5c/0x98 fs/btrfs/volumes.c:1395
       btrfs_control_ioctl+0x12c/0x248 fs/btrfs/super.c:2451
       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

-> #2 (&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
       write_all_supers+0x134c/0x3a6c fs/btrfs/disk-io.c:4159
       btrfs_sync_log+0x19c8/0x2294 fs/btrfs/tree-log.c:3327
       btrfs_sync_file+0xa70/0xfd4 fs/btrfs/file.c:2373
       vfs_fsync_range+0x168/0x188 fs/sync.c:188
       generic_write_sync include/linux/fs.h:2989 [inline]
       btrfs_file_write_iter+0x5b8/0xb6c fs/btrfs/file.c:2101
       do_iter_readv_writev+0x420/0x5f8
       do_iter_write+0x1b8/0x66c fs/read_write.c:855
       vfs_writev fs/read_write.c:928 [inline]
       do_pwritev+0x1ec/0x334 fs/read_write.c:1025
       __do_sys_pwritev2 fs/read_write.c:1084 [inline]
       __se_sys_pwritev2 fs/read_write.c:1075 [inline]
       __arm64_sys_pwritev2+0xd4/0x108 fs/read_write.c:1075
       __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

-> #1 (&fs_info->tree_log_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_sync_log+0x1904/0x2294 fs/btrfs/tree-log.c:3308
       btrfs_sync_file+0xa70/0xfd4 fs/btrfs/file.c:2373
       vfs_fsync_range+0x168/0x188 fs/sync.c:188
       generic_write_sync include/linux/fs.h:2989 [inline]
       btrfs_file_write_iter+0x5b8/0xb6c fs/btrfs/file.c:2101
       do_iter_readv_writev+0x420/0x5f8
       do_iter_write+0x1b8/0x66c fs/read_write.c:855
       vfs_writev fs/read_write.c:928 [inline]
       do_pwritev+0x1ec/0x334 fs/read_write.c:1025
       __do_sys_pwritev2 fs/read_write.c:1084 [inline]
       __se_sys_pwritev2 fs/read_write.c:1075 [inline]
       __arm64_sys_pwritev2+0xd4/0x108 fs/read_write.c:1075
       __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 (sb_internal#3){.+.+}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3053 [inline]
       check_prevs_add kernel/locking/lockdep.c:3172 [inline]
       validate_chain kernel/locking/lockdep.c:3788 [inline]
       __lock_acquire+0x32d4/0x7638 kernel/locking/lockdep.c:5012
       lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5623
       percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
       __sb_start_write include/linux/fs.h:1811 [inline]
       sb_start_intwrite include/linux/fs.h:1928 [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:6435
       btrfs_update_time+0x248/0x270 fs/btrfs/inode.c:6477
       inode_update_time fs/inode.c:1864 [inline]
       touch_atime+0x434/0xa4c fs/inode.c:1937
       file_accessed include/linux/fs.h:2521 [inline]
       btrfs_file_mmap+0xb0/0x11c fs/btrfs/file.c:2451
       call_mmap include/linux/fs.h:2177 [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

other info that might help us debug this:

Chain exists of:
  sb_internal#3 --> &tree->tree_lock#2 --> &mm->mmap_lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&mm->mmap_lock);
                               lock(&tree->tree_lock#2);
                               lock(&mm->mmap_lock);
  lock(sb_internal#3);

 *** DEADLOCK ***

2 locks held by syz.1.421/5864:
 #0: ffff0000d8eb62d8 (&mm->mmap_lock){++++}-{3:3}, at: mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline]
 #0: ffff0000d8eb62d8 (&mm->mmap_lock){++++}-{3:3}, at: vm_mmap_pgoff+0x15c/0x2b4 mm/util.c:549
 #1: ffff0000d57ec460 (sb_writers#14){.+.+}-{0:0}, at: file_accessed include/linux/fs.h:2521 [inline]
 #1: ffff0000d57ec460 (sb_writers#14){.+.+}-{0:0}, at: btrfs_file_mmap+0xb0/0x11c fs/btrfs/file.c:2451

stack backtrace:
CPU: 0 PID: 5864 Comm: syz.1.421 Not tainted 5.15.167-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
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:3788 [inline]
 __lock_acquire+0x32d4/0x7638 kernel/locking/lockdep.c:5012
 lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5623
 percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
 __sb_start_write include/linux/fs.h:1811 [inline]
 sb_start_intwrite include/linux/fs.h:1928 [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:6435
 btrfs_update_time+0x248/0x270 fs/btrfs/inode.c:6477
 inode_update_time fs/inode.c:1864 [inline]
 touch_atime+0x434/0xa4c fs/inode.c:1937
 file_accessed include/linux/fs.h:2521 [inline]
 btrfs_file_mmap+0xb0/0x11c fs/btrfs/file.c:2451
 call_mmap include/linux/fs.h:2177 [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

Crashes (32):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/09/21 04:01 linux-5.15.y 3a5928702e71 6f888b75 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/09/17 19:52 linux-5.15.y 3a5928702e71 c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/08/28 21:22 linux-5.15.y fa93fa65db6e ef3de9e8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/08/24 03:02 linux-5.15.y fa93fa65db6e d7d32352 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/08/24 03:00 linux-5.15.y fa93fa65db6e d7d32352 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/08/24 02:55 linux-5.15.y fa93fa65db6e d7d32352 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/08/24 02:15 linux-5.15.y fa93fa65db6e d7d32352 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/08/03 16:37 linux-5.15.y 7e89efd3ae1c 1786a2a8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/07/29 20:11 linux-5.15.y 7e89efd3ae1c 5187fc86 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/07/28 22:57 linux-5.15.y 7e89efd3ae1c 46eb10b7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/07/25 12:33 linux-5.15.y 7c6d66f0266f 466a14e5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/07/25 12:31 linux-5.15.y 7c6d66f0266f 466a14e5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/07/24 22:32 linux-5.15.y 7c6d66f0266f d1a1b0ca .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/07/21 00:23 linux-5.15.y 7c6d66f0266f b88348e9 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/07/20 08:26 linux-5.15.y 7c6d66f0266f b88348e9 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/07/18 09:24 linux-5.15.y f45bea23c39c 0f902625 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/07/18 00:18 linux-5.15.y f45bea23c39c 0f902625 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/07/14 04:08 linux-5.15.y f45bea23c39c eaeb5c15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/07/14 04:08 linux-5.15.y f45bea23c39c eaeb5c15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/05/11 14:34 linux-5.15.y 284087d4f7d5 9026e142 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/05/05 17:39 linux-5.15.y 284087d4f7d5 610f2a54 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/05/05 03:30 linux-5.15.y 284087d4f7d5 610f2a54 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/05/05 03:28 linux-5.15.y 284087d4f7d5 610f2a54 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/05/02 02:17 linux-5.15.y b925f60c6ee7 3ba885bc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/04/30 18:30 linux-5.15.y b925f60c6ee7 3ce4924c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/04/30 16:34 linux-5.15.y b925f60c6ee7 3ce4924c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/04/22 07:56 linux-5.15.y c52b9710c83d af24b050 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/04/21 20:24 linux-5.15.y c52b9710c83d af24b050 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/04/20 14:48 linux-5.15.y c52b9710c83d af24b050 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/04/07 21:19 linux-5.15.y 9465fef4ae35 ca620dd8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/04/01 19:06 linux-5.15.y 9465fef4ae35 6baf5069 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
2024/01/20 21:23 linux-5.15.y ddcaf4999061 9bd8dcda .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in btrfs_join_transaction
* Struck through repros no longer work on HEAD.