syzbot


possible deadlock in do_page_mkwrite

Status: upstream: reported C repro on 2023/04/29 03:26
Bug presence: origin:upstream
Labels: missing-backport
[Documentation on labels]
Reported-by: syzbot+dde175863b2f8fc68611@syzkaller.appspotmail.com
First crash: 611d, last: 18d
Fix commit to backport (bisect log) :
tree: upstream
commit fb6f20ecb121cef4d7946f834a6ee867c4e21b4a
Author: Jan Kara <jack@suse.cz>
Date: Thu Oct 17 10:28:23 2024 +0000

  reiserfs: The last commit

  
Fix bisection: failed (error log, bisect log)
  
Bug presence (3)
Date Name Commit Repro Result
2024/12/12 linux-6.1.y (ToT) e4d90d63d385 C [report] possible deadlock in do_page_mkwrite
2023/06/18 upstream (ToT) 45a3e24f65e9 C [report] possible deadlock in do_page_mkwrite
2024/12/12 upstream (ToT) 231825b2e1ff 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 dri 2 5d08h 30d 0/28 upstream: reported on 2024/11/30 09:50
upstream possible deadlock in do_page_mkwrite reiserfs C error done 114 335d 749d 0/28 auto-obsoleted due to no activity on 2024/04/09 15:57
linux-5.15 possible deadlock in do_page_mkwrite origin:upstream missing-backport C 7 20d 567d 0/3 upstream: reported C repro on 2023/06/12 00:09
Fix bisection attempts (9)
Created Duration User Patch Repo Result
2024/12/26 13:46 8h59m fix candidate upstream OK (1) job log
2024/10/15 00:27 0m bisect fix linux-6.1.y error job log
2024/09/06 12:19 1h46m bisect fix linux-6.1.y OK (0) job log log
2024/08/02 06:00 1h59m bisect fix linux-6.1.y OK (0) job log log
2024/06/19 06:48 2h10m bisect fix linux-6.1.y OK (0) job log log
2024/04/17 11:43 2h26m bisect fix linux-6.1.y OK (0) job log log
2024/02/02 15:22 2h29m bisect fix linux-6.1.y OK (0) job log log
2023/12/30 06:57 1h30m bisect fix linux-6.1.y OK (0) job log log
2023/08/01 23:36 2h58m bisect fix linux-6.1.y OK (0) job log log

Sample crash report:
REISERFS (device loop0): journal params: device loop0, size 512, journal first block 18, max trans len 256, max batch 225, max commit age 30, max trans age 30
REISERFS (device loop0): checking transaction log (loop0)
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
6.1.53-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor235/3543 is trying to acquire lock:
ffff8880182ec090 (&sbi->lock){+.+.}-{3:3}, at: reiserfs_write_lock+0x76/0xd0 fs/reiserfs/lock.c:27

but task is already holding lock:
ffff8880792b8558 (sb_pagefaults){.+.+}-{0:0}, at: do_page_mkwrite+0x1a1/0x5f0 mm/memory.c:2982

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (sb_pagefaults){.+.+}-{0:0}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5661
       percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
       __sb_start_write include/linux/fs.h:1832 [inline]
       sb_start_pagefault include/linux/fs.h:1936 [inline]
       filemap_page_mkwrite+0x16a/0x630 mm/filemap.c:3421
       do_page_mkwrite+0x1a1/0x5f0 mm/memory.c:2982
       do_shared_fault mm/memory.c:4647 [inline]
       do_fault mm/memory.c:4715 [inline]
       handle_pte_fault mm/memory.c:4983 [inline]
       __handle_mm_fault mm/memory.c:5125 [inline]
       handle_mm_fault+0x22e8/0x5330 mm/memory.c:5246
       do_user_addr_fault arch/x86/mm/fault.c:1380 [inline]
       handle_page_fault arch/x86/mm/fault.c:1471 [inline]
       exc_page_fault+0x26f/0x660 arch/x86/mm/fault.c:1527
       asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570
       copy_user_enhanced_fast_string+0xa/0x40 arch/x86/lib/copy_user_64.S:165
       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:170 [inline]
       _copy_to_iter+0x2c1/0xfe0 lib/iov_iter.c:527
       copy_page_to_iter+0xac/0x170 lib/iov_iter.c:725
       copy_folio_to_iter include/linux/uio.h:172 [inline]
       filemap_read+0x273e/0x31d0 mm/filemap.c:2727
       call_read_iter include/linux/fs.h:2199 [inline]
       new_sync_read fs/read_write.c:389 [inline]
       vfs_read+0x7de/0xbe0 fs/read_write.c:470
       ksys_read+0x19c/0x2c0 fs/read_write.c:613
       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 (&mm->mmap_lock){++++}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5661
       __might_fault+0xb2/0x110 mm/memory.c:5801
       reiserfs_ioctl+0x11d/0x340 fs/reiserfs/ioctl.c:96
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:870 [inline]
       __se_sys_ioctl+0xf1/0x160 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

-> #0 (&sbi->lock){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain+0x1667/0x58e0 kernel/locking/lockdep.c:3824
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5048
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5661
       __mutex_lock_common+0x1d4/0x2520 kernel/locking/mutex.c:603
       __mutex_lock kernel/locking/mutex.c:747 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
       reiserfs_write_lock+0x76/0xd0 fs/reiserfs/lock.c:27
       reiserfs_dirty_inode+0xee/0x240 fs/reiserfs/super.c:704
       __mark_inode_dirty+0x331/0xf80 fs/fs-writeback.c:2411
       generic_update_time fs/inode.c:1901 [inline]
       inode_update_time fs/inode.c:1914 [inline]
       __file_update_time+0x221/0x240 fs/inode.c:2102
       file_update_time+0x34c/0x3c0 fs/inode.c:2133
       filemap_page_mkwrite+0x275/0x630 mm/filemap.c:3422
       do_page_mkwrite+0x1a1/0x5f0 mm/memory.c:2982
       do_shared_fault mm/memory.c:4647 [inline]
       do_fault mm/memory.c:4715 [inline]
       handle_pte_fault mm/memory.c:4983 [inline]
       __handle_mm_fault mm/memory.c:5125 [inline]
       handle_mm_fault+0x22e8/0x5330 mm/memory.c:5246
       do_user_addr_fault arch/x86/mm/fault.c:1380 [inline]
       handle_page_fault arch/x86/mm/fault.c:1471 [inline]
       exc_page_fault+0x26f/0x660 arch/x86/mm/fault.c:1527
       asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570
       copy_user_enhanced_fast_string+0xa/0x40 arch/x86/lib/copy_user_64.S:165
       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:170 [inline]
       _copy_to_iter+0x2c1/0xfe0 lib/iov_iter.c:527
       copy_page_to_iter+0xac/0x170 lib/iov_iter.c:725
       copy_folio_to_iter include/linux/uio.h:172 [inline]
       filemap_read+0x273e/0x31d0 mm/filemap.c:2727
       call_read_iter include/linux/fs.h:2199 [inline]
       new_sync_read fs/read_write.c:389 [inline]
       vfs_read+0x7de/0xbe0 fs/read_write.c:470
       ksys_read+0x19c/0x2c0 fs/read_write.c:613
       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:
  &sbi->lock --> &mm->mmap_lock --> sb_pagefaults

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

2 locks held by syz-executor235/3543:
 #0: ffff88807d90d3d8 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_trylock include/linux/mmap_lock.h:136 [inline]
 #0: ffff88807d90d3d8 (&mm->mmap_lock){++++}-{3:3}, at: get_mmap_lock_carefully mm/memory.c:5274 [inline]
 #0: ffff88807d90d3d8 (&mm->mmap_lock){++++}-{3:3}, at: lock_mm_and_find_vma+0x2e/0x2e0 mm/memory.c:5336
 #1: ffff8880792b8558 (sb_pagefaults){.+.+}-{0:0}, at: do_page_mkwrite+0x1a1/0x5f0 mm/memory.c:2982

stack backtrace:
CPU: 1 PID: 3543 Comm: syz-executor235 Not tainted 6.1.53-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2fa/0x3b0 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+0x1667/0x58e0 kernel/locking/lockdep.c:3824
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5048
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5661
 __mutex_lock_common+0x1d4/0x2520 kernel/locking/mutex.c:603
 __mutex_lock kernel/locking/mutex.c:747 [inline]
 mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
 reiserfs_write_lock+0x76/0xd0 fs/reiserfs/lock.c:27
 reiserfs_dirty_inode+0xee/0x240 fs/reiserfs/super.c:704
 __mark_inode_dirty+0x331/0xf80 fs/fs-writeback.c:2411
 generic_update_time fs/inode.c:1901 [inline]
 inode_update_time fs/inode.c:1914 [inline]
 __file_update_time+0x221/0x240 fs/inode.c:2102
 file_update_time+0x34c/0x3c0 fs/inode.c:2133
 filemap_page_mkwrite+0x275/0x630 mm/filemap.c:3422
 do_page_mkwrite+0x1a1/0x5f0 mm/memory.c:2982
 do_shared_fault mm/memory.c:4647 [inline]
 do_fault mm/memory.c:4715 [inline]
 handle_pte_fault mm/memory.c:4983 [inline]
 __handle_mm_fault mm/memory.c:5125 [inline]
 handle_mm_fault+0x22e8/0x5330 mm/memory.c:5246
 do_user_addr_fault arch/x86/mm/fault.c:1380 [inline]
 handle_page_fault arch/x86/mm/fault.c:1471 [inline]
 exc_page_fault+0x26f/0x660 arch/x86/mm/fault.c:1527
 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570
RIP: 0010:copy_user_enhanced_fast_string+0xa/0x40 arch/x86/lib/copy_user_64.S:166
Code: ff c9 75 f2 89 d1 c1 e9 03 83 e2 07 f3 48 a5 89 d1 f3 a4 31 c0 0f 01 ca c3 8d 0c ca 89 ca eb 20 0f 01 cb 83 fa 40 72 38 89 d1 <f3> a4 31 c0 0f 01 ca c3 89 ca eb 0a 66 2e 0f 1f 84 00 00 00 00 00
RSP: 0018:ffffc9000396f798 EFLAGS: 00050206
RAX: ffffffff8432fb01 RBX: 0000000000001000 RCX: 0000000000001000
RDX: 0000000000001000 RSI: ffff88807eba2000 RDI: 0000000020001740
RBP: ffffc9000396f8f8 R08: dffffc0000000000 R09: ffffed100fd74600
R10: 0000000000000000 R11: dffffc0000000001 R12: ffff88807eba2000
R13: 1ffff9200072dfb3 R14: 0000000000001000 R15: dffffc0000000000
 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:170 [inline]
 _copy_to_iter+0x2c1/0xfe0 lib/iov_iter.c:527
 copy_page_to_iter+0xac/0x170 lib/iov_iter.c:725
 copy_folio_to_iter include/linux/uio.h:172 [inline]
 filemap_read+0x273e/0x31d0 mm/filemap.c:2727
 call_read_iter include/linux/fs.h:2199 [inline]
 new_sync_read fs/read_write.c:389 [inline]
 vfs_read+0x7de/0xbe0 fs/read_write.c:470
 ksys_read+0x19c/0x2c0 fs/read_write.c:613
 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:0x7ff25d5e1c79
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
RSP: 002b:00007ffcf2fa99c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00007ff25d5ad896 RCX: 00007ff25d5e1c79
RDX: 0000000000002020 RSI: 0000000020001740 RDI: 0000000000000005
RBP: 00007ff25d656610 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00007ffcf2fa9b98 R14: 0000000000000001 R15: 0000000000000001
----------------
Code disassembly (best guess):
   0:	ff c9                	dec    %ecx
   2:	75 f2                	jne    0xfffffff6
   4:	89 d1                	mov    %edx,%ecx
   6:	c1 e9 03             	shr    $0x3,%ecx
   9:	83 e2 07             	and    $0x7,%edx
   c:	f3 48 a5             	rep movsq %ds:(%rsi),%es:(%rdi)
   f:	89 d1                	mov    %edx,%ecx
  11:	f3 a4                	rep movsb %ds:(%rsi),%es:(%rdi)
  13:	31 c0                	xor    %eax,%eax
  15:	0f 01 ca             	clac
  18:	c3                   	ret
  19:	8d 0c ca             	lea    (%rdx,%rcx,8),%ecx
  1c:	89 ca                	mov    %ecx,%edx
  1e:	eb 20                	jmp    0x40
  20:	0f 01 cb             	stac
  23:	83 fa 40             	cmp    $0x40,%edx
  26:	72 38                	jb     0x60
  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:	89 ca                	mov    %ecx,%edx
  34:	eb 0a                	jmp    0x40
  36:	66 2e 0f 1f 84 00 00 	cs nopw 0x0(%rax,%rax,1)
  3d:	00 00 00

Crashes (10):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/09/16 10:28 linux-6.1.y 09045dae0d90 0b6a67ac .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-6-1-kasan possible deadlock in do_page_mkwrite
2023/06/18 13:50 linux-6.1.y ca87e77a2ef8 f3921d4d .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-6-1-kasan possible deadlock in do_page_mkwrite
2024/03/11 07:19 linux-6.1.y 61adba85cc40 6ee49f2e .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-6-1-kasan-arm64 possible deadlock in do_page_mkwrite
2024/03/14 18:13 linux-6.1.y 61adba85cc40 8d8ee116 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in do_page_mkwrite
2023/11/27 07:43 linux-6.1.y 69e434a1cb21 5b429f39 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in do_page_mkwrite
2024/05/15 14:09 linux-6.1.y 909ba1f1b414 94b087b1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in do_page_mkwrite
2023/11/30 06:00 linux-6.1.y 6ac30d748bb0 f819d6f7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in do_page_mkwrite
2023/11/22 18:12 linux-6.1.y 69e434a1cb21 03e12510 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in do_page_mkwrite
2023/10/19 22:54 linux-6.1.y 7d24402875c7 42e1d524 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in do_page_mkwrite
2023/04/29 03:26 linux-6.1.y ca1c9012c941 62df2017 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in do_page_mkwrite
* Struck through repros no longer work on HEAD.