[v6.1] possible deadlock in do_page_mkwrite

0 views
Skip to first unread message

syzbot

unread,
Apr 28, 2023, 11:26:51 PM4/28/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: ca1c9012c941 Linux 6.1.26
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=14e53ca0280000
kernel config: https://syzkaller.appspot.com/x/.config?x=f749f501f45a424b
dashboard link: https://syzkaller.appspot.com/bug?extid=dde175863b2f8fc68611
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/fa9c42c5de02/disk-ca1c9012.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/deeadb7af907/vmlinux-ca1c9012.xz
kernel image: https://storage.googleapis.com/syzbot-assets/3b2d047683d5/bzImage-ca1c9012.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+dde175...@syzkaller.appspotmail.com

syz-executor.3 (6659): drop_caches: 2
======================================================
WARNING: possible circular locking dependency detected
6.1.26-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.3/6659 is trying to acquire lock:
ffff88807308f090 (&sbi->lock){+.+.}-{3:3}, at: reiserfs_write_lock+0x76/0xd0 fs/reiserfs/lock.c:27

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

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (sb_pagefaults#2){.+.+}-{0:0}:
lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5669
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:2973
wp_page_shared+0x164/0x380 mm/memory.c:3319
handle_pte_fault mm/memory.c:4982 [inline]
__handle_mm_fault mm/memory.c:5106 [inline]
handle_mm_fault+0x2522/0x5330 mm/memory.c:5227
do_user_addr_fault arch/x86/mm/fault.c:1428 [inline]
handle_page_fault arch/x86/mm/fault.c:1519 [inline]
exc_page_fault+0x58d/0x790 arch/x86/mm/fault.c:1575
asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570

-> #1 (&mm->mmap_lock#2){++++}-{3:3}:
lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5669
__might_fault+0xb2/0x110 mm/memory.c:5655
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:3098 [inline]
check_prevs_add kernel/locking/lockdep.c:3217 [inline]
validate_chain+0x1667/0x58e0 kernel/locking/lockdep.c:3832
__lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5056
lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5669
__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:1859 [inline]
inode_update_time fs/inode.c:1872 [inline]
__file_update_time+0x221/0x240 fs/inode.c:2060
file_update_time+0x34c/0x3c0 fs/inode.c:2091
filemap_page_mkwrite+0x275/0x630 mm/filemap.c:3422
do_page_mkwrite+0x1a1/0x5f0 mm/memory.c:2973
wp_page_shared+0x164/0x380 mm/memory.c:3319
handle_pte_fault mm/memory.c:4982 [inline]
__handle_mm_fault mm/memory.c:5106 [inline]
handle_mm_fault+0x2522/0x5330 mm/memory.c:5227
do_user_addr_fault arch/x86/mm/fault.c:1428 [inline]
handle_page_fault arch/x86/mm/fault.c:1519 [inline]
exc_page_fault+0x58d/0x790 arch/x86/mm/fault.c:1575
asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570
__put_user_nocheck_8+0x3/0x21
__do_sys_sendfile64 fs/read_write.c:1318 [inline]
__se_sys_sendfile64+0x138/0x1e0 fs/read_write.c:1309
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#2 --> sb_pagefaults#2

Possible unsafe locking scenario:

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

*** DEADLOCK ***

2 locks held by syz-executor.3/6659:
#0: ffff88807d99e2d8 (&mm->mmap_lock#2){++++}-{3:3}, at: mmap_read_trylock include/linux/mmap_lock.h:136 [inline]
#0: ffff88807d99e2d8 (&mm->mmap_lock#2){++++}-{3:3}, at: do_user_addr_fault arch/x86/mm/fault.c:1369 [inline]
#0: ffff88807d99e2d8 (&mm->mmap_lock#2){++++}-{3:3}, at: handle_page_fault arch/x86/mm/fault.c:1519 [inline]
#0: ffff88807d99e2d8 (&mm->mmap_lock#2){++++}-{3:3}, at: exc_page_fault+0x182/0x790 arch/x86/mm/fault.c:1575
#1: ffff888027330558 (sb_pagefaults#2){.+.+}-{0:0}, at: do_page_mkwrite+0x1a1/0x5f0 mm/memory.c:2973

stack backtrace:
CPU: 0 PID: 6659 Comm: syz-executor.3 Not tainted 6.1.26-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/14/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:2178
check_prev_add kernel/locking/lockdep.c:3098 [inline]
check_prevs_add kernel/locking/lockdep.c:3217 [inline]
validate_chain+0x1667/0x58e0 kernel/locking/lockdep.c:3832
__lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5056
lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5669
__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:1859 [inline]
inode_update_time fs/inode.c:1872 [inline]
__file_update_time+0x221/0x240 fs/inode.c:2060
file_update_time+0x34c/0x3c0 fs/inode.c:2091
filemap_page_mkwrite+0x275/0x630 mm/filemap.c:3422
do_page_mkwrite+0x1a1/0x5f0 mm/memory.c:2973
wp_page_shared+0x164/0x380 mm/memory.c:3319
handle_pte_fault mm/memory.c:4982 [inline]
__handle_mm_fault mm/memory.c:5106 [inline]
handle_mm_fault+0x2522/0x5330 mm/memory.c:5227
do_user_addr_fault arch/x86/mm/fault.c:1428 [inline]
handle_page_fault arch/x86/mm/fault.c:1519 [inline]
exc_page_fault+0x58d/0x790 arch/x86/mm/fault.c:1575
asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570
RIP: 0010:__put_user_nocheck_8+0x3/0x21
Code: 00 00 48 39 d9 73 34 0f 01 cb 89 01 31 c9 0f 01 ca c3 66 0f 1f 44 00 00 48 bb f9 ef ff ff ff 7f 00 00 48 39 d9 73 14 0f 01 cb <48> 89 01 31 c9 0f 01 ca c3 0f 1f 44 00 00 0f 01 ca b9 f2 ff ff ff
RSP: 0018:ffffc9000629fe58 EFLAGS: 00050297
RAX: 000000000000006c RBX: 00007fffffffeff9 RCX: 0000000020002080
RDX: 0000000000000000 RSI: ffffffff8aebe1a0 RDI: ffffffff8b3cbfa0
RBP: ffffc9000629ff20 R08: dffffc0000000000 R09: fffffbfff1ca5da6
R10: 0000000000000000 R11: dffffc0000000001 R12: 0000000020002080
R13: dffffc0000000000 R14: 000000000000000c R15: 1ffff92000c53fd4
__do_sys_sendfile64 fs/read_write.c:1318 [inline]
__se_sys_sendfile64+0x138/0x1e0 fs/read_write.c:1309
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:0x7f1b0288c169
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 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:00007f1af93dd168 EFLAGS: 00000246 ORIG_RAX: 0000000000000028
RAX: ffffffffffffffda RBX: 00007f1b029ac050 RCX: 00007f1b0288c169
RDX: 0000000020002080 RSI: 0000000000000007 RDI: 0000000000000008
RBP: 00007f1b028e7ca1 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000870 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffee533c66f R14: 00007f1af93dd300 R15: 0000000000022000
</TASK>
----------------
Code disassembly (best guess):
0: 00 00 add %al,(%rax)
2: 48 39 d9 cmp %rbx,%rcx
5: 73 34 jae 0x3b
7: 0f 01 cb stac
a: 89 01 mov %eax,(%rcx)
c: 31 c9 xor %ecx,%ecx
e: 0f 01 ca clac
11: c3 retq
12: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
18: 48 bb f9 ef ff ff ff movabs $0x7fffffffeff9,%rbx
1f: 7f 00 00
22: 48 39 d9 cmp %rbx,%rcx
25: 73 14 jae 0x3b
27: 0f 01 cb stac
* 2a: 48 89 01 mov %rax,(%rcx) <-- trapping instruction
2d: 31 c9 xor %ecx,%ecx
2f: 0f 01 ca clac
32: c3 retq
33: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
38: 0f 01 ca clac
3b: b9 f2 ff ff ff mov $0xfffffff2,%ecx


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to change bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Jun 18, 2023, 9:51:05 AM6/18/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: ca87e77a2ef8 Linux 6.1.34
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=159ebbcf280000
kernel config: https://syzkaller.appspot.com/x/.config?x=c188e92022a334b
dashboard link: https://syzkaller.appspot.com/bug?extid=dde175863b2f8fc68611
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13ea0f73280000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15379337280000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/f48d514c343c/disk-ca87e77a.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/563336f1f216/vmlinux-ca87e77a.xz
kernel image: https://storage.googleapis.com/syzbot-assets/2254afa3642b/bzImage-ca87e77a.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/8a4cbeab7239/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+dde175...@syzkaller.appspotmail.com

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 (device loop0): using 3.5.x disk format
REISERFS (device loop0): Created .reiserfs_priv - reserved for xattr storage.
======================================================
WARNING: possible circular locking dependency detected
6.1.34-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor764/3652 is trying to acquire lock:
ffff88807f6d4090 (&sbi->lock){+.+.}-{3:3}, at: reiserfs_write_lock+0x76/0xd0 fs/reiserfs/lock.c:27

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

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:5669
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:2973
do_shared_fault mm/memory.c:4628 [inline]
do_fault mm/memory.c:4696 [inline]
handle_pte_fault mm/memory.c:4964 [inline]
__handle_mm_fault mm/memory.c:5106 [inline]
handle_mm_fault+0x22e8/0x5330 mm/memory.c:5227
do_shared_fault mm/memory.c:4628 [inline]
do_fault mm/memory.c:4696 [inline]
handle_pte_fault mm/memory.c:4964 [inline]
__handle_mm_fault mm/memory.c:5106 [inline]
handle_mm_fault+0x22e8/0x5330 mm/memory.c:5227
do_user_addr_fault arch/x86/mm/fault.c:1428 [inline]
handle_page_fault arch/x86/mm/fault.c:1519 [inline]
exc_page_fault+0x58d/0x790 arch/x86/mm/fault.c:1575
asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570

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 ***

2 locks held by syz-executor764/3652:
#0: ffff88807c9662d8 (&mm->mmap_lock#2){++++}-{3:3}, at: mmap_read_lock include/linux/mmap_lock.h:117 [inline]
#0: ffff88807c9662d8 (&mm->mmap_lock#2){++++}-{3:3}, at: do_user_addr_fault arch/x86/mm/fault.c:1379 [inline]
#0: ffff88807c9662d8 (&mm->mmap_lock#2){++++}-{3:3}, at: handle_page_fault arch/x86/mm/fault.c:1519 [inline]
#0: ffff88807c9662d8 (&mm->mmap_lock#2){++++}-{3:3}, at: exc_page_fault+0x46a/0x790 arch/x86/mm/fault.c:1575
#1: ffff88807e124558 (sb_pagefaults){.+.+}-{0:0}, at: do_page_mkwrite+0x1a1/0x5f0 mm/memory.c:2973

stack backtrace:
CPU: 1 PID: 3652 Comm: syz-executor764 Not tainted 6.1.34-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/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:2178
check_prev_add kernel/locking/lockdep.c:3098 [inline]
check_prevs_add kernel/locking/lockdep.c:3217 [inline]
validate_chain+0x1667/0x58e0 kernel/locking/lockdep.c:3832
__lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5056
lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5669
__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:1859 [inline]
inode_update_time fs/inode.c:1872 [inline]
__file_update_time+0x221/0x240 fs/inode.c:2060
file_update_time+0x34c/0x3c0 fs/inode.c:2091
filemap_page_mkwrite+0x275/0x630 mm/filemap.c:3422
do_page_mkwrite+0x1a1/0x5f0 mm/memory.c:2973
do_shared_fault mm/memory.c:4628 [inline]
do_fault mm/memory.c:4696 [inline]
handle_pte_fault mm/memory.c:4964 [inline]
__handle_mm_fault mm/memory.c:5106 [inline]
handle_mm_fault+0x22e8/0x5330 mm/memory.c:5227
do_user_addr_fault arch/x86/mm/fault.c:1428 [inline]
handle_page_fault arch/x86/mm/fault.c:1519 [inline]
exc_page_fault+0x58d/0x790 arch/x86/mm/fault.c:1575
asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570
RIP: 0033:0x7f5f27a0b525
Code: 09 00 00 00 e8 fc 24 04 00 48 8b 35 35 5c 0b 00 ba ff 7f 00 02 31 c0 bf 4d 00 00 00 e8 e4 24 04 00 31 c9 ba 42 da 14 00 31 c0 <c7> 04 25 c0 00 00 20 2e 2f 62 75 be c0 00 00 20 bf 02 00 00 00 66
RSP: 002b:00007ffef9e48bb0 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 00000000000947ed RCX: 0000000000000000
RDX: 000000000014da42 RSI: 0000000002007fff RDI: 0000000000000004
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000005 R11: 0000000000000246 R12: 00007ffef9e48bdc
R13: 00007ffef9e48c10 R14: 00007ffef9e48bf0 R15: 0000000000000021
</TASK>


---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
Reply all
Reply to author
Forward
0 new messages