[syzbot] [mm?] possible deadlock in move_pages (2)

From: syzbot
Date: Sun Dec 22 2024 - 02:37:33 EST


Hello,

syzbot found the following issue on:

HEAD commit: 7fa366f1b6e3 Add linux-next specific files for 20241218
git tree: linux-next
console+strace: https://syzkaller.appspot.com/x/log.txt?x=14bbc2df980000
kernel config: https://syzkaller.appspot.com/x/.config?x=26a4b4cc7f877b28
dashboard link: https://syzkaller.appspot.com/bug?extid=eedb611600ae59683656
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16cd6f44580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12bbc2df980000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/76406ccde331/disk-7fa366f1.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/49c56a285987/vmlinux-7fa366f1.xz
kernel image: https://storage.googleapis.com/syzbot-assets/92d20cf0cd8a/bzImage-7fa366f1.xz

The issue was bisected to:

commit 032377449a80095d3526d263414fa7216bac5b2a
Author: Suren Baghdasaryan <surenb@xxxxxxxxxx>
Date: Mon Dec 16 19:24:13 2024 +0000

mm: replace vm_lock and detached flag with a reference count

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1078a2df980000
final oops: https://syzkaller.appspot.com/x/report.txt?x=1278a2df980000
console output: https://syzkaller.appspot.com/x/log.txt?x=1478a2df980000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+eedb611600ae59683656@xxxxxxxxxxxxxxxxxxxxxxxxx
Fixes: 032377449a80 ("mm: replace vm_lock and detached flag with a reference count")

============================================
WARNING: possible recursive locking detected
6.13.0-rc3-next-20241218-syzkaller #0 Not tainted
--------------------------------------------
syz-executor591/5830 is trying to acquire lock:
ffff8880122abc08 (vm_lock){++++}-{0:0}, at: uffd_move_lock mm/userfaultfd.c:1477 [inline]
ffff8880122abc08 (vm_lock){++++}-{0:0}, at: move_pages+0x26b/0x1680 mm/userfaultfd.c:1632

but task is already holding lock:
ffff88823bfcafc8 (vm_lock){++++}-{0:0}, at: vma_start_read_locked include/linux/mm.h:803 [inline]
ffff88823bfcafc8 (vm_lock){++++}-{0:0}, at: uffd_lock_vma+0x20c/0x2c0 mm/userfaultfd.c:88

other info that might help us debug this:
Possible unsafe locking scenario:

CPU0
----
lock(vm_lock);
lock(vm_lock);

*** DEADLOCK ***

May be due to missing lock nesting notation

2 locks held by syz-executor591/5830:
#0: ffff88823bfcafc8 (vm_lock){++++}-{0:0}, at: vma_start_read_locked include/linux/mm.h:803 [inline]
#0: ffff88823bfcafc8 (vm_lock){++++}-{0:0}, at: uffd_lock_vma+0x20c/0x2c0 mm/userfaultfd.c:88
#1: ffffffff8e937d20 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire include/linux/rcupdate.h:337 [inline]
#1: ffffffff8e937d20 (rcu_read_lock){....}-{1:3}, at: rcu_read_lock include/linux/rcupdate.h:849 [inline]
#1: ffffffff8e937d20 (rcu_read_lock){....}-{1:3}, at: lock_vma_under_rcu+0x1dd/0xa40 mm/memory.c:6422

stack backtrace:
CPU: 0 UID: 0 PID: 5830 Comm: syz-executor591 Not tainted 6.13.0-rc3-next-20241218-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/25/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
print_deadlock_bug+0x483/0x620 kernel/locking/lockdep.c:3037
check_deadlock kernel/locking/lockdep.c:3089 [inline]
validate_chain+0x15e2/0x5920 kernel/locking/lockdep.c:3891
__lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226
lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
vma_start_read include/linux/mm.h:744 [inline]
lock_vma_under_rcu+0x370/0xa40 mm/memory.c:6427
uffd_move_lock mm/userfaultfd.c:1477 [inline]
move_pages+0x26b/0x1680 mm/userfaultfd.c:1632
userfaultfd_move fs/userfaultfd.c:1899 [inline]
userfaultfd_ioctl+0x5221/0x6840 fs/userfaultfd.c:2022
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:906 [inline]
__se_sys_ioctl+0xf5/0x170 fs/ioctl.c:892
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7ff238379329
Code: 48 83 c4 28 c3 e8 37 17 00 00 0f 1f 80 00 00 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffca8233748 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007ffca8233918 RCX: 00007ff238379329
RDX: 0000000020000080 RSI: 00000000c028aa05 RDI: 0000000000000003
RBP: 00007


---
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 syzkaller@xxxxxxxxxxxxxxxx.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection

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

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.

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

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

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