syzbot


possible deadlock in do_page_mkwrite (3)

Status: upstream: reported on 2025/06/15 09:03
Subsystems: kernfs
[Documentation on labels]
Reported-by: syzbot+47c7d1a51f51d13f5723@syzkaller.appspotmail.com
First crash: 295d, last: 8d13h
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [kernfs?] possible deadlock in do_page_mkwrite (3) 0 (1) 2025/06/15 09:03
Similar bugs (4)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in do_page_mkwrite (2) dri 4 5 428d 487d 0/29 auto-obsoleted due to no activity on 2025/05/09 03:36
linux-6.1 possible deadlock in do_page_mkwrite origin:upstream missing-backport 4 C done 16 78d 1069d 0/3 upstream: reported C repro on 2023/04/29 03:26
upstream possible deadlock in do_page_mkwrite fs 4 C error done 114 792d 1207d 0/29 auto-obsoleted due to no activity on 2024/04/09 15:57
linux-5.15 possible deadlock in do_page_mkwrite missing-backport origin:upstream 4 C done 21 28d 1025d 0/3 upstream: reported C repro on 2023/06/12 00:09

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.5.270/7905 is trying to acquire lock:
ffff88802a90a5f8 (sb_pagefaults#2){.+.+}-{0:0}, at: do_page_mkwrite+0x150/0x310 mm/memory.c:3589

but task is already holding lock:
ffff888019c4d238 (&root->kernfs_rwsem){++++}-{4:4}, at: kernfs_fop_readdir+0x275/0x8d0 fs/kernfs/dir.c:1898

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #4 (&root->kernfs_rwsem){++++}-{4:4}:
       down_write+0x3a/0x50 kernel/locking/rwsem.c:1590
       kernfs_add_one+0x41/0x5c0 fs/kernfs/dir.c:796
       kernfs_create_dir_ns+0xde/0x130 fs/kernfs/dir.c:1098
       sysfs_create_dir_ns+0x12f/0x2a0 fs/sysfs/dir.c:59
       create_dir lib/kobject.c:73 [inline]
       kobject_add_internal+0x631/0xd10 lib/kobject.c:240
       kobject_add_varg lib/kobject.c:374 [inline]
       kobject_init_and_add+0x12b/0x1a0 lib/kobject.c:457
       btrfs_sysfs_add_qgroups+0x116/0x2e0 fs/btrfs/sysfs.c:2604
       btrfs_quota_enable+0x282/0x2850 fs/btrfs/qgroup.c:1034
       btrfs_ioctl_quota_ctl+0x186/0x1c0 fs/btrfs/ioctl.c:3540
       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 (&fs_info->qgroup_ioctl_lock){+.+.}-{4:4}:
       __mutex_lock_common kernel/locking/rtmutex_api.c:533 [inline]
       mutex_lock_nested+0x5a/0x1d0 kernel/locking/rtmutex_api.c:552
       btrfs_quota_enable+0x2c6/0x2850 fs/btrfs/qgroup.c:1063
       btrfs_ioctl_quota_ctl+0x186/0x1c0 fs/btrfs/ioctl.c:3540
       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

-> #2 (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_dirty_inode+0x9f/0x190 fs/btrfs/inode.c:6443
       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 (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

-> #0 (sb_pagefaults#2){.+.+}-{0:0}:
       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
       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
       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+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
       filldir+0x2b5/0x690 fs/readdir.c:295
       dir_emit include/linux/fs.h:3566 [inline]
       kernfs_fop_readdir+0x57e/0x8d0 fs/kernfs/dir.c:1915
       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:
  sb_pagefaults#2 --> &fs_info->qgroup_ioctl_lock --> &root->kernfs_rwsem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(&root->kernfs_rwsem);
                               lock(&fs_info->qgroup_ioctl_lock);
                               lock(&root->kernfs_rwsem);
  rlock(sb_pagefaults#2);

 *** DEADLOCK ***

4 locks held by syz.5.270/7905:
 #0: ffff888035eedd28 (&f->f_pos_lock){+.+.}-{4:4}, at: fdget_pos+0x252/0x320 fs/file.c:1261
 #1: ffff88804090d978 (&type->i_mutex_dir_key#6){++++}-{4:4}, at: iterate_dir+0x29e/0x580 fs/readdir.c:101
 #2: ffff888019c4d238 (&root->kernfs_rwsem){++++}-{4:4}, at: kernfs_fop_readdir+0x275/0x8d0 fs/kernfs/dir.c:1898
 #3: ffff888035cfd1b0 (&mm->mmap_lock){++++}-{4:4}, at: mmap_read_trylock include/linux/mmap_lock.h:611 [inline]
 #3: ffff888035cfd1b0 (&mm->mmap_lock){++++}-{4:4}, at: get_mmap_lock_carefully mm/mmap_lock.c:441 [inline]
 #3: ffff888035cfd1b0 (&mm->mmap_lock){++++}-{4:4}, at: lock_mm_and_find_vma+0x36/0x340 mm/mmap_lock.c:501

stack backtrace:
CPU: 0 UID: 0 PID: 7905 Comm: syz.5.270 Not tainted syzkaller #0 PREEMPT_{RT,(full)} 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/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
 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
 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+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
RIP: 0010:filldir+0x2b5/0x690 fs/readdir.c:296
Code: 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 8b 54 24 1c <66> 89 41 10 80 e2 0f 41 89 c7 42 88 54 39 ff 49 63 ee c6 44 29 12
RSP: 0018:ffffc90005f6fc40 EFLAGS: 00050283
RAX: 0000000000000020 RBX: ffffc90005f6fe38 RCX: 0000200000001ff0
RDX: 0000000000000008 RSI: 0000200000001fd8 RDI: 0000200000002010
RBP: 00007ffffffff000 R08: 0000000000000000 R09: 0000000000000000
R10: dffffc0000000000 R11: ffffed1004e5f001 R12: 0000200000001fd8
R13: ffff888019c6c5c0 R14: 000000000000000b R15: 0000200000002010
 dir_emit include/linux/fs.h:3566 [inline]
 kernfs_fop_readdir+0x57e/0x8d0 fs/kernfs/dir.c:1915
 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:0x7f1855dcc799
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:00007f184bc05028 EFLAGS: 00000246 ORIG_RAX: 000000000000004e
RAX: ffffffffffffffda RBX: 00007f1856046090 RCX: 00007f1855dcc799
RDX: 00000000000000b8 RSI: 0000200000001fc0 RDI: 0000000000000009
RBP: 00007f1855e62c99 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f1856046128 R14: 00007f1856046090 R15: 00007ffd166a1708
 </TASK>
----------------
Code disassembly (best guess):
   0:	87 73 02             	xchg   %esi,0x2(%rbx)
   3:	00 00                	add    %al,(%rax)
   5:	0f 01 cb             	stac
   8:	0f ae e8             	lfence
   b:	48 8b 44 24 50       	mov    0x50(%rsp),%rax
  10:	49 89 44 24 08       	mov    %rax,0x8(%r12)
  15:	48 8b 4c 24 08       	mov    0x8(%rsp),%rcx
  1a:	48 8b 44 24 58       	mov    0x58(%rsp),%rax
  1f:	48 89 01             	mov    %rax,(%rcx)
  22:	48 8b 04 24          	mov    (%rsp),%rax
  26:	8b 54 24 1c          	mov    0x1c(%rsp),%edx
* 2a:	66 89 41 10          	mov    %ax,0x10(%rcx) <-- trapping instruction
  2e:	80 e2 0f             	and    $0xf,%dl
  31:	41 89 c7             	mov    %eax,%r15d
  34:	42 88 54 39 ff       	mov    %dl,-0x1(%rcx,%r15,1)
  39:	49 63 ee             	movslq %r14d,%rbp
  3c:	c6                   	.byte 0xc6
  3d:	44 29 12             	sub    %r10d,(%rdx)

Crashes (9):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/03/24 20:26 upstream e3c33bc767b5 74e70d19 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in do_page_mkwrite
2026/03/13 03:08 upstream 0257f64bdac7 2f7f359d .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in do_page_mkwrite
2026/02/19 02:45 upstream c22e26bd0906 77d4d919 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in do_page_mkwrite
2025/12/12 02:13 upstream d358e5254674 d6526ea3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in do_page_mkwrite
2025/10/27 09:49 upstream dcb6fa37fd7b c0460fcd .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in do_page_mkwrite
2025/08/26 04:24 upstream b6add54ba618 bf27483f .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in do_page_mkwrite
2025/07/26 21:35 upstream 302f88ff3584 fb8f743d .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in do_page_mkwrite
2025/06/11 08:56 upstream aef17cb3d3c4 5d7e17ca .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in do_page_mkwrite
2025/06/11 08:56 upstream aef17cb3d3c4 5d7e17ca .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in do_page_mkwrite
* Struck through repros no longer work on HEAD.