syzbot


possible deadlock in do_page_mkwrite

Status: upstream: reported C repro on 2023/06/12 00:09
Bug presence: origin:upstream
Labels: missing-backport
[Documentation on labels]
Reported-by: syzbot+734fef9ab106cbaa9556@syzkaller.appspotmail.com
First crash: 558d, last: 11d
Bug presence (3)
Date Name Commit Repro Result
2024/12/09 linux-5.15.y (ToT) 0a51d2d4527b C [report] possible deadlock in do_page_mkwrite
2023/06/12 upstream (ToT) 858fd168a95c C [report] possible deadlock in do_page_mkwrite
2024/12/09 upstream (ToT) fac04efc5c79 C Didn't crash
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in do_page_mkwrite (2) block trace 1 25d 21d 0/28 upstream: reported on 2024/11/30 09:50
linux-6.1 possible deadlock in do_page_mkwrite origin:upstream missing-backport C error 10 9d05h 602d 0/3 upstream: reported C repro on 2023/04/29 03:26
upstream possible deadlock in do_page_mkwrite reiserfs C error done 114 325d 740d 0/28 auto-obsoleted due to no activity on 2024/04/09 15:57
Last patch testing requests (1)
Created Duration User Patch Repo Result
2024/10/23 15:42 15m retest repro linux-5.15.y report log
Fix bisection attempts (12)
Created Duration User Patch Repo Result
2024/12/03 01:14 3h01m bisect fix linux-5.15.y OK (0) job log log
2024/10/08 08:57 2h43m bisect fix linux-5.15.y OK (0) job log log
2024/08/03 18:46 1h09m bisect fix linux-5.15.y OK (0) job log log
2024/06/24 04:43 1h52m bisect fix linux-5.15.y OK (0) job log log
2024/04/16 14:14 1h27m bisect fix linux-5.15.y OK (0) job log log
2024/03/13 14:13 1h18m bisect fix linux-5.15.y OK (0) job log log
2024/02/08 19:55 1h18m bisect fix linux-5.15.y OK (0) job log log
2024/01/04 04:45 1h08m bisect fix linux-5.15.y OK (0) job log log
2023/12/04 07:50 1h17m bisect fix linux-5.15.y OK (0) job log log
2023/11/03 09:00 1h17m bisect fix linux-5.15.y OK (0) job log log
2023/10/03 11:01 1h24m bisect fix linux-5.15.y OK (0) job log log
2023/07/24 12:38 4h06m bisect fix linux-5.15.y OK (0) job log log

Sample crash report:
REISERFS (device loop0): Using r5 hash to sort names
reiserfs: enabling write barrier flush mode
REISERFS (device loop0): Created .reiserfs_priv - reserved for xattr storage.
======================================================
WARNING: possible circular locking dependency detected
5.15.124-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor392/3498 is trying to acquire lock:
ffff888147edf090 (&sbi->lock){+.+.}-{3:3}, at: reiserfs_write_lock+0x76/0xd0 fs/reiserfs/lock.c:27

but task is already holding lock:
ffff888078012558 (sb_pagefaults){.+.+}-{0:0}, at: do_page_mkwrite+0x1a9/0x440 mm/memory.c:2892

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (sb_pagefaults){.+.+}-{0:0}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622
       percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
       __sb_start_write include/linux/fs.h:1742 [inline]
       sb_start_pagefault include/linux/fs.h:1841 [inline]
       filemap_page_mkwrite+0x11b/0x650 mm/filemap.c:3358
       do_page_mkwrite+0x1a9/0x440 mm/memory.c:2892
       do_shared_fault mm/memory.c:4298 [inline]
       do_fault mm/memory.c:4366 [inline]
       handle_pte_fault mm/memory.c:4621 [inline]
       __handle_mm_fault mm/memory.c:4756 [inline]
       handle_mm_fault+0x2803/0x5950 mm/memory.c:4854
       do_user_addr_fault arch/x86/mm/fault.c:1397 [inline]
       handle_page_fault arch/x86/mm/fault.c:1485 [inline]
       exc_page_fault+0x271/0x740 arch/x86/mm/fault.c:1541
       asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:568
       copy_user_enhanced_fast_string+0xe/0x40 arch/x86/lib/copy_user_64.S:205
       copy_user_generic arch/x86/include/asm/uaccess_64.h:37 [inline]
       raw_copy_to_user arch/x86/include/asm/uaccess_64.h:58 [inline]
       copyout lib/iov_iter.c:157 [inline]
       copy_page_to_iter_iovec lib/iov_iter.c:228 [inline]
       __copy_page_to_iter lib/iov_iter.c:861 [inline]
       copy_page_to_iter+0x49a/0x10d0 lib/iov_iter.c:889
       filemap_read+0x20f6/0x2980 mm/filemap.c:2689
       call_read_iter include/linux/fs.h:2097 [inline]
       new_sync_read fs/read_write.c:404 [inline]
       vfs_read+0xa9f/0xe10 fs/read_write.c:485
       ksys_read+0x1a2/0x2c0 fs/read_write.c:623
       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+0x61/0xcb

-> #1 (&mm->mmap_lock#2){++++}-{3:3}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622
       __might_fault+0xb4/0x110 mm/memory.c:5324
       reiserfs_ioctl+0x11d/0x340 fs/reiserfs/ioctl.c:96
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:874 [inline]
       __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860
       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+0x61/0xcb

-> #0 (&sbi->lock){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3053 [inline]
       check_prevs_add kernel/locking/lockdep.c:3172 [inline]
       validate_chain+0x1646/0x58b0 kernel/locking/lockdep.c:3787
       __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5011
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622
       __mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
       reiserfs_write_lock+0x76/0xd0 fs/reiserfs/lock.c:27
       reiserfs_dirty_inode+0xee/0x240 fs/reiserfs/super.c:704
       __mark_inode_dirty+0x2fd/0xd60 fs/fs-writeback.c:2442
       generic_update_time+0x1cb/0x1e0 fs/inode.c:1817
       inode_update_time fs/inode.c:1830 [inline]
       file_update_time+0x3eb/0x460 fs/inode.c:2019
       filemap_page_mkwrite+0x222/0x650 mm/filemap.c:3359
       do_page_mkwrite+0x1a9/0x440 mm/memory.c:2892
       do_shared_fault mm/memory.c:4298 [inline]
       do_fault mm/memory.c:4366 [inline]
       handle_pte_fault mm/memory.c:4621 [inline]
       __handle_mm_fault mm/memory.c:4756 [inline]
       handle_mm_fault+0x2803/0x5950 mm/memory.c:4854
       do_user_addr_fault arch/x86/mm/fault.c:1397 [inline]
       handle_page_fault arch/x86/mm/fault.c:1485 [inline]
       exc_page_fault+0x271/0x740 arch/x86/mm/fault.c:1541
       asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:568
       copy_user_enhanced_fast_string+0xe/0x40 arch/x86/lib/copy_user_64.S:205
       copy_user_generic arch/x86/include/asm/uaccess_64.h:37 [inline]
       raw_copy_to_user arch/x86/include/asm/uaccess_64.h:58 [inline]
       copyout lib/iov_iter.c:157 [inline]
       copy_page_to_iter_iovec lib/iov_iter.c:228 [inline]
       __copy_page_to_iter lib/iov_iter.c:861 [inline]
       copy_page_to_iter+0x49a/0x10d0 lib/iov_iter.c:889
       filemap_read+0x20f6/0x2980 mm/filemap.c:2689
       call_read_iter include/linux/fs.h:2097 [inline]
       new_sync_read fs/read_write.c:404 [inline]
       vfs_read+0xa9f/0xe10 fs/read_write.c:485
       ksys_read+0x1a2/0x2c0 fs/read_write.c:623
       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+0x61/0xcb

other info that might help us debug this:

Chain exists of:
  &sbi->lock --> &mm->mmap_lock#2 --> sb_pagefaults

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(sb_pagefaults);
                               lock(&mm->mmap_lock#2);
                               lock(sb_pagefaults);
  lock(&sbi->lock);

 *** DEADLOCK ***

3 locks held by syz-executor392/3498:
 #0: ffff88807f56e870 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x21c/0x2b0 fs/file.c:1072
 #1: ffff888078798f28 (&mm->mmap_lock#2){++++}-{3:3}, at: mmap_read_trylock include/linux/mmap_lock.h:136 [inline]
 #1: ffff888078798f28 (&mm->mmap_lock#2){++++}-{3:3}, at: do_user_addr_fault arch/x86/mm/fault.c:1338 [inline]
 #1: ffff888078798f28 (&mm->mmap_lock#2){++++}-{3:3}, at: handle_page_fault arch/x86/mm/fault.c:1485 [inline]
 #1: ffff888078798f28 (&mm->mmap_lock#2){++++}-{3:3}, at: exc_page_fault+0x181/0x740 arch/x86/mm/fault.c:1541
 #2: ffff888078012558 (sb_pagefaults){.+.+}-{0:0}, at: do_page_mkwrite+0x1a9/0x440 mm/memory.c:2892

stack backtrace:
CPU: 0 PID: 3498 Comm: syz-executor392 Not tainted 5.15.124-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2f8/0x3b0 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+0x1646/0x58b0 kernel/locking/lockdep.c:3787
 __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5011
 lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622
 __mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
 __mutex_lock kernel/locking/mutex.c:729 [inline]
 mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
 reiserfs_write_lock+0x76/0xd0 fs/reiserfs/lock.c:27
 reiserfs_dirty_inode+0xee/0x240 fs/reiserfs/super.c:704
 __mark_inode_dirty+0x2fd/0xd60 fs/fs-writeback.c:2442
 generic_update_time+0x1cb/0x1e0 fs/inode.c:1817
 inode_update_time fs/inode.c:1830 [inline]
 file_update_time+0x3eb/0x460 fs/inode.c:2019
 filemap_page_mkwrite+0x222/0x650 mm/filemap.c:3359
 do_page_mkwrite+0x1a9/0x440 mm/memory.c:2892
 do_shared_fault mm/memory.c:4298 [inline]
 do_fault mm/memory.c:4366 [inline]
 handle_pte_fault mm/memory.c:4621 [inline]
 __handle_mm_fault mm/memory.c:4756 [inline]
 handle_mm_fault+0x2803/0x5950 mm/memory.c:4854
 do_user_addr_fault arch/x86/mm/fault.c:1397 [inline]
 handle_page_fault arch/x86/mm/fault.c:1485 [inline]
 exc_page_fault+0x271/0x740 arch/x86/mm/fault.c:1541
 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:568
RIP: 0010:copy_user_enhanced_fast_string+0xe/0x40 arch/x86/lib/copy_user_64.S:206
Code: 89 d1 c1 e9 03 83 e2 07 f3 48 a5 89 d1 f3 a4 31 c0 0f 01 ca c3 0f 1f 80 00 00 00 00 0f 01 cb 83 fa 40 0f 82 70 ff ff ff 89 d1 <f3> a4 31 c0 0f 01 ca c3 66 2e 0f 1f 84 00 00 00 00 00 89 d1 83 f8
RSP: 0018:ffffc900020ef8b0 EFLAGS: 00050206
RAX: ffffffff84049c01 RBX: 0000000020002740 RCX: 0000000000001000
RDX: 0000000000001000 RSI: ffff888072dc8000 RDI: 0000000020001740
RBP: ffffc900020efd20 R08: dffffc0000000000 R09: ffffed100e5b9200
R10: 0000000000000000 R11: dffffc0000000001 R12: 0000000020001740
R13: 0000000000001000 R14: ffff888072dc8000 R15: 00007ffffffff000
 copy_user_generic arch/x86/include/asm/uaccess_64.h:37 [inline]
 raw_copy_to_user arch/x86/include/asm/uaccess_64.h:58 [inline]
 copyout lib/iov_iter.c:157 [inline]
 copy_page_to_iter_iovec lib/iov_iter.c:228 [inline]
 __copy_page_to_iter lib/iov_iter.c:861 [inline]
 copy_page_to_iter+0x49a/0x10d0 lib/iov_iter.c:889
 filemap_read+0x20f6/0x2980 mm/filemap.c:2689
 call_read_iter include/linux/fs.h:2097 [inline]
 new_sync_read fs/read_write.c:404 [inline]
 vfs_read+0xa9f/0xe10 fs/read_write.c:485
 ksys_read+0x1a2/0x2c0 fs/read_write.c:623
 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+0x61/0xcb
RIP: 0033:0x7f343c133c79
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 61 17 00 00 90 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 b8 ff ff ff f7 d8 64 89 01 48
----------------
Code disassembly (best guess):
   0:	89 d1                	mov    %edx,%ecx
   2:	c1 e9 03             	shr    $0x3,%ecx
   5:	83 e2 07             	and    $0x7,%edx
   8:	f3 48 a5             	rep movsq %ds:(%rsi),%es:(%rdi)
   b:	89 d1                	mov    %edx,%ecx
   d:	f3 a4                	rep movsb %ds:(%rsi),%es:(%rdi)
   f:	31 c0                	xor    %eax,%eax
  11:	0f 01 ca             	clac
  14:	c3                   	ret
  15:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)
  1c:	0f 01 cb             	stac
  1f:	83 fa 40             	cmp    $0x40,%edx
  22:	0f 82 70 ff ff ff    	jb     0xffffff98
  28:	89 d1                	mov    %edx,%ecx
* 2a:	f3 a4                	rep movsb %ds:(%rsi),%es:(%rdi) <-- trapping instruction
  2c:	31 c0                	xor    %eax,%eax
  2e:	0f 01 ca             	clac
  31:	c3                   	ret
  32:	66 2e 0f 1f 84 00 00 	cs nopw 0x0(%rax,%rax,1)
  39:	00 00 00
  3c:	89 d1                	mov    %edx,%ecx
  3e:	83                   	.byte 0x83
  3f:	f8                   	clc

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/08/06 15:13 linux-5.15.y 38d4ca22a528 4ffcc9ef .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-5-15-kasan possible deadlock in do_page_mkwrite
2023/06/12 00:08 linux-5.15.y 7349e40704a0 49519f06 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-5-15-kasan possible deadlock in do_page_mkwrite
2024/05/14 03:48 linux-5.15.y 284087d4f7d5 fdb4c10c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in do_page_mkwrite
2024/08/25 11:31 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 do_page_mkwrite
2024/05/16 21:01 linux-5.15.y 284087d4f7d5 c2e07261 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in do_page_mkwrite
2024/05/14 11:18 linux-5.15.y 284087d4f7d5 fdb4c10c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in do_page_mkwrite
2024/05/02 19:17 linux-5.15.y 284087d4f7d5 3ba885bc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in do_page_mkwrite
* Struck through repros no longer work on HEAD.