syzbot


possible deadlock in btrfs_dirty_inode

Status: upstream: reported C repro on 2022/11/14 17:54
Reported-by: syzbot+37edf86c9b60581e523f@syzkaller.appspotmail.com
First crash: 14d, last: 2d19h

Cause bisection: failed (bisect log)
Patch testing requests:
Created Duration User Patch Repo Result
2022/11/15 06:49 29m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git e01d50cbd6ee OK log

Sample crash report:
BTRFS info (device loop0): using xxhash64 (xxhash64-generic) checksum algorithm
BTRFS info (device loop0): using free space tree
BTRFS info (device loop0): enabling ssd optimizations
======================================================
WARNING: possible circular locking dependency detected
6.1.0-rc5-syzkaller-00326-g77c51ba552a1 #0 Not tainted
------------------------------------------------------
syz-executor891/3664 is trying to acquire lock:
ffff88802a25e650 (sb_internal#2){.+.+}-{0:0}, at: btrfs_dirty_inode+0xcc/0x1c0 fs/btrfs/inode.c:6085

but task is already holding lock:
ffff88807d905118 (&mm->mmap_lock#2){++++}-{3:3}, at: mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline]
ffff88807d905118 (&mm->mmap_lock#2){++++}-{3:3}, at: vm_mmap_pgoff+0x14d/0x2b0 mm/util.c:518

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #5 (&mm->mmap_lock#2){++++}-{3:3}:
       lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
       __might_fault+0xb2/0x110 mm/memory.c:5646
       _copy_to_user+0x26/0x130 lib/usercopy.c:29
       copy_to_user include/linux/uaccess.h:169 [inline]
       btrfs_ioctl_get_subvol_rootref+0x8cf/0xa90 fs/btrfs/ioctl.c:3203
       btrfs_ioctl+0xb7c/0xc10 fs/btrfs/ioctl.c:5556
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:870 [inline]
       __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:856
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #4 (btrfs-root-00){++++}-{3:3}:
       lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
       down_read_nested+0x3c/0x50 kernel/locking/rwsem.c:1634
       __btrfs_tree_read_lock fs/btrfs/locking.c:134 [inline]
       btrfs_tree_read_lock fs/btrfs/locking.c:140 [inline]
       btrfs_read_lock_root_node+0x2b4/0x400 fs/btrfs/locking.c:279
       btrfs_search_slot_get_root fs/btrfs/ctree.c:1665 [inline]
       btrfs_search_slot+0x495/0x2fe0 fs/btrfs/ctree.c:1985
       btrfs_update_root+0xf0/0xc60 fs/btrfs/root-tree.c:132
       commit_fs_roots+0x4d3/0x710 fs/btrfs/transaction.c:1441
       btrfs_commit_transaction+0x147f/0x3760 fs/btrfs/transaction.c:2353
       sync_filesystem+0x1bc/0x220 fs/sync.c:66
       generic_shutdown_super+0x6b/0x310 fs/super.c:474
       kill_anon_super+0x36/0x60 fs/super.c:1086
       btrfs_kill_super+0x3d/0x50 fs/btrfs/super.c:2441
       deactivate_locked_super+0xa7/0xf0 fs/super.c:332
       cleanup_mnt+0x494/0x520 fs/namespace.c:1186
       task_work_run+0x243/0x300 kernel/task_work.c:179
       ptrace_notify+0x29a/0x340 kernel/signal.c:2354
       ptrace_report_syscall include/linux/ptrace.h:420 [inline]
       ptrace_report_syscall_exit include/linux/ptrace.h:482 [inline]
       syscall_exit_work+0x8c/0xe0 kernel/entry/common.c:251
       syscall_exit_to_user_mode_prepare+0x63/0xc0 kernel/entry/common.c:278
       __syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline]
       syscall_exit_to_user_mode+0xa/0x60 kernel/entry/common.c:296
       do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #3 (&fs_info->reloc_mutex){+.+.}-{3:3}:
       lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
       __mutex_lock_common+0x1bd/0x26e0 kernel/locking/mutex.c:603
       __mutex_lock kernel/locking/mutex.c:747 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
       btrfs_record_root_in_trans+0x153/0x180 fs/btrfs/transaction.c:484
       start_transaction+0x3af/0x1180 fs/btrfs/transaction.c:721
       btrfs_create_common+0x2c6/0x420 fs/btrfs/inode.c:6633
       lookup_open fs/namei.c:3413 [inline]
       open_last_lookups fs/namei.c:3481 [inline]
       path_openat+0x12d0/0x2df0 fs/namei.c:3710
       do_filp_open+0x264/0x4f0 fs/namei.c:3740
       do_sys_openat2+0x124/0x4e0 fs/open.c:1310
       do_sys_open fs/open.c:1326 [inline]
       __do_sys_openat fs/open.c:1342 [inline]
       __se_sys_openat fs/open.c:1337 [inline]
       __x64_sys_openat+0x243/0x290 fs/open.c:1337
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #2 (btrfs_trans_num_extwriters){++++}-{0:0}:
       lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
       join_transaction+0x19f/0xe60 fs/btrfs/transaction.c:299
       start_transaction+0x6fb/0x1180 fs/btrfs/transaction.c:658
       btrfs_create_common+0x2c6/0x420 fs/btrfs/inode.c:6633
       lookup_open fs/namei.c:3413 [inline]
       open_last_lookups fs/namei.c:3481 [inline]
       path_openat+0x12d0/0x2df0 fs/namei.c:3710
       do_filp_open+0x264/0x4f0 fs/namei.c:3740
       do_sys_openat2+0x124/0x4e0 fs/open.c:1310
       do_sys_open fs/open.c:1326 [inline]
       __do_sys_openat fs/open.c:1342 [inline]
       __se_sys_openat fs/open.c:1337 [inline]
       __x64_sys_openat+0x243/0x290 fs/open.c:1337
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #1 (btrfs_trans_num_writers){++++}-{0:0}:
       lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
       join_transaction+0x17a/0xe60 fs/btrfs/transaction.c:298
       start_transaction+0x6fb/0x1180 fs/btrfs/transaction.c:658
       btrfs_create_common+0x2c6/0x420 fs/btrfs/inode.c:6633
       lookup_open fs/namei.c:3413 [inline]
       open_last_lookups fs/namei.c:3481 [inline]
       path_openat+0x12d0/0x2df0 fs/namei.c:3710
       do_filp_open+0x264/0x4f0 fs/namei.c:3740
       do_sys_openat2+0x124/0x4e0 fs/open.c:1310
       do_sys_open fs/open.c:1326 [inline]
       __do_sys_openat fs/open.c:1342 [inline]
       __se_sys_openat fs/open.c:1337 [inline]
       __x64_sys_openat+0x243/0x290 fs/open.c:1337
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 (sb_internal#2){.+.+}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3097 [inline]
       check_prevs_add kernel/locking/lockdep.c:3216 [inline]
       validate_chain+0x1898/0x6ae0 kernel/locking/lockdep.c:3831
       __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055
       lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
       percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
       __sb_start_write include/linux/fs.h:1826 [inline]
       sb_start_intwrite include/linux/fs.h:1948 [inline]
       start_transaction+0x5cb/0x1180 fs/btrfs/transaction.c:652
       btrfs_dirty_inode+0xcc/0x1c0 fs/btrfs/inode.c:6085
       inode_update_time fs/inode.c:1871 [inline]
       touch_atime+0x315/0x630 fs/inode.c:1944
       file_accessed include/linux/fs.h:2521 [inline]
       btrfs_file_mmap+0xbb/0x120 fs/btrfs/file.c:2333
       call_mmap include/linux/fs.h:2196 [inline]
       mmap_region+0xfe6/0x1e20 mm/mmap.c:2625
       do_mmap+0x8d9/0xf30 mm/mmap.c:1412
       vm_mmap_pgoff+0x19e/0x2b0 mm/util.c:520
       ksys_mmap_pgoff+0x48c/0x6d0 mm/mmap.c:1458
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

other info that might help us debug this:

Chain exists of:
  sb_internal#2 --> btrfs-root-00 --> &mm->mmap_lock#2

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&mm->mmap_lock#2);
                               lock(btrfs-root-00);
                               lock(&mm->mmap_lock#2);
  lock(sb_internal#2);

 *** DEADLOCK ***

2 locks held by syz-executor891/3664:
 #0: ffff88807d905118 (&mm->mmap_lock#2){++++}-{3:3}, at: mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline]
 #0: ffff88807d905118 (&mm->mmap_lock#2){++++}-{3:3}, at: vm_mmap_pgoff+0x14d/0x2b0 mm/util.c:518
 #1: ffff88802a25e460 (sb_writers#9){.+.+}-{0:0}, at: file_accessed include/linux/fs.h:2521 [inline]
 #1: ffff88802a25e460 (sb_writers#9){.+.+}-{0:0}, at: btrfs_file_mmap+0xbb/0x120 fs/btrfs/file.c:2333

stack backtrace:
CPU: 0 PID: 3664 Comm: syz-executor891 Not tainted 6.1.0-rc5-syzkaller-00326-g77c51ba552a1 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106
 check_noncircular+0x2cc/0x390 kernel/locking/lockdep.c:2177
 check_prev_add kernel/locking/lockdep.c:3097 [inline]
 check_prevs_add kernel/locking/lockdep.c:3216 [inline]
 validate_chain+0x1898/0x6ae0 kernel/locking/lockdep.c:3831
 __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055
 lock_acquire+0x182/0x3c0 kernel/locking/lockdep.c:5668
 percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
 __sb_start_write include/linux/fs.h:1826 [inline]
 sb_start_intwrite include/linux/fs.h:1948 [inline]
 start_transaction+0x5cb/0x1180 fs/btrfs/transaction.c:652
 btrfs_dirty_inode+0xcc/0x1c0 fs/btrfs/inode.c:6085
 inode_update_time fs/inode.c:1871 [inline]
 touch_atime+0x315/0x630 fs/inode.c:1944
 file_accessed include/linux/fs.h:2521 [inline]
 btrfs_file_mmap+0xbb/0x120 fs/btrfs/file.c:2333
 call_mmap include/linux/fs.h:2196 [inline]
 mmap_region+0xfe6/0x1e20 mm/mmap.c:2625
 do_mmap+0x8d9/0xf30 mm/mmap.c:1412
 vm_mmap_pgoff+0x19e/0x2b0 mm/util.c:520
 ksys_mmap_pgoff+0x48c/0x6d0 mm/mmap.c:1458
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f5854bf8679
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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffc9d6974a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000009
RAX: ffffffffffffffda RBX: 00007f5854c40938 RCX: 00007f5854bf8679
RDX: 0000000000000000 RSI: 0000000000400000 RDI: 0000000020000000
RBP: 00007f5854c40850 R08: 0000000000000003 R09: 0000000000000000
R10: 0000000000010012 R11: 0000000000000246 R12: 00007f5854c40708
R13: 00007f5854c406a0 R14: 00007ffc9d6974f0 R15: 0000000000000001
 </TASK>

Crashes (48):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-upstream-fs 2022/11/20 21:25 upstream 77c51ba552a1 5bb70014 .config log report syz C possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/18 11:23 upstream 84368d882b96 5bb70014 .config log report syz C possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/15 02:40 upstream e01d50cbd6ee 97de9cfc .config log report syz C possible deadlock in btrfs_dirty_inode
ci-upstream-kasan-gce-root 2022/11/26 16:30 upstream 0b1dcc2cf55a 74a66371 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/26 11:32 upstream 08ad43d554ba f4470a7b .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/26 09:59 upstream 08ad43d554ba f4470a7b .config log report info possible deadlock in btrfs_dirty_inode
ci-upstream-kasan-gce-selinux-root 2022/11/26 06:14 upstream 0b1dcc2cf55a 74a66371 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/26 05:10 upstream 08ad43d554ba f4470a7b .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/26 01:37 upstream 08ad43d554ba f4470a7b .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/25 15:59 upstream c3eb11fbb826 74a66371 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/25 13:43 upstream c3eb11fbb826 74a66371 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/25 05:16 upstream c3eb11fbb826 74a66371 .config log report info possible deadlock in btrfs_dirty_inode
ci-upstream-kasan-gce-root 2022/11/25 02:36 upstream c3eb11fbb826 62e26685 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/25 01:10 upstream 4312098baf37 ff68ff8f .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/25 00:46 upstream 4312098baf37 ff68ff8f .config log report info possible deadlock in btrfs_dirty_inode
ci-upstream-kasan-gce-root 2022/11/25 00:24 upstream c3eb11fbb826 62e26685 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/24 20:41 upstream 4312098baf37 ff68ff8f .config log report info possible deadlock in btrfs_dirty_inode
ci-upstream-kasan-gce-selinux-root 2022/11/24 18:29 upstream c3eb11fbb826 62e26685 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/24 08:42 upstream 4312098baf37 ff68ff8f .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/24 03:08 upstream eb7081409f94 52fdf57a .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/24 01:58 upstream eb7081409f94 52fdf57a .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/23 19:24 upstream eb7081409f94 52fdf57a .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/23 07:06 upstream eb7081409f94 9da37ae8 .config log report info possible deadlock in btrfs_dirty_inode
ci-upstream-kasan-gce-smack-root 2022/11/23 02:30 upstream eb7081409f94 9da37ae8 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/23 01:40 upstream eb7081409f94 9da37ae8 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/22 21:32 upstream eb7081409f94 9da37ae8 .config log report info possible deadlock in btrfs_dirty_inode
ci-upstream-kasan-gce-root 2022/11/22 20:53 upstream eb7081409f94 9da37ae8 .config log report info possible deadlock in btrfs_dirty_inode
ci-upstream-kasan-gce-smack-root 2022/11/22 15:39 upstream eb7081409f94 1c576c23 .config log report info possible deadlock in btrfs_dirty_inode
ci-upstream-kasan-gce-root 2022/11/22 12:25 upstream eb7081409f94 1c576c23 .config log report info possible deadlock in btrfs_dirty_inode
ci-upstream-kasan-gce-root 2022/11/22 12:01 upstream eb7081409f94 1c576c23 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/21 20:21 upstream eb7081409f94 1c576c23 .config log report info possible deadlock in btrfs_dirty_inode
ci-upstream-kasan-gce-root 2022/11/21 11:01 upstream 77c51ba552a1 5bb70014 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/20 23:02 upstream 77c51ba552a1 5bb70014 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/18 10:12 upstream 84368d882b96 5bb70014 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/17 04:48 upstream 59d0d52c30d4 3a127a31 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/17 04:15 upstream 59d0d52c30d4 3a127a31 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/16 18:03 upstream 59d0d52c30d4 3a127a31 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/16 15:07 upstream 81e7cfa3a9eb 3a127a31 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/16 09:14 upstream 81e7cfa3a9eb 3a127a31 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/16 06:57 upstream 81e7cfa3a9eb 3a127a31 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/16 03:01 upstream 81e7cfa3a9eb 3a127a31 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/15 13:38 upstream e01d50cbd6ee 97de9cfc .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/14 21:15 upstream 094226ad94f4 943f4cb8 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/14 19:04 upstream 094226ad94f4 943f4cb8 .config log report info possible deadlock in btrfs_dirty_inode
ci2-upstream-fs 2022/11/14 17:37 upstream 094226ad94f4 943f4cb8 .config log report info possible deadlock in btrfs_dirty_inode
ci-qemu-upstream-386 2022/11/22 04:32 upstream eb7081409f94 1c576c23 .config log report info possible deadlock in btrfs_dirty_inode
* Struck through repros no longer work on HEAD.