[syzbot] [mm?] possible deadlock in mmap_read_lock

From: syzbot
Date: Fri Jul 19 2024 - 16:01:36 EST


Hello,

syzbot found the following issue on:

HEAD commit: 3fe121b62282 Add linux-next specific files for 20240712
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=1769e695980000
kernel config: https://syzkaller.appspot.com/x/.config?x=98dd8c4bab5cdce
dashboard link: https://syzkaller.appspot.com/bug?extid=c0f0941337ade4c26ed1
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/8c6fbf69718d/disk-3fe121b6.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/39fc7e43dfc1/vmlinux-3fe121b6.xz
kernel image: https://storage.googleapis.com/syzbot-assets/0a78e70e4b4e/bzImage-3fe121b6.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c0f0941337ade4c26ed1@xxxxxxxxxxxxxxxxxxxxxxxxx


============================================
WARNING: possible recursive locking detected
6.10.0-rc7-next-20240712-syzkaller #0 Not tainted
--------------------------------------------
mount/4518 is trying to acquire lock:
ffff88801d2b1498 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock+0x1c/0x60 include/linux/mmap_lock.h:144

but task is already holding lock:
ffff88801d2b1498 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock include/linux/mmap_lock.h:144 [inline]
ffff88801d2b1498 (&mm->mmap_lock){++++}-{3:3}, at: exit_mmap+0x159/0xc80 mm/mmap.c:3396

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

CPU0
----
lock(&mm->mmap_lock);
lock(&mm->mmap_lock);

*** DEADLOCK ***

May be due to missing lock nesting notation

1 lock held by mount/4518:
#0: ffff88801d2b1498 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock include/linux/mmap_lock.h:144 [inline]
#0: ffff88801d2b1498 (&mm->mmap_lock){++++}-{3:3}, at: exit_mmap+0x159/0xc80 mm/mmap.c:3396

stack backtrace:
CPU: 1 UID: 0 PID: 4518 Comm: mount Not tainted 6.10.0-rc7-next-20240712-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/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:3034
check_deadlock kernel/locking/lockdep.c:3086 [inline]
validate_chain+0x15e2/0x5920 kernel/locking/lockdep.c:3888
__lock_acquire+0x1384/0x2050 kernel/locking/lockdep.c:5199
lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5822
down_read+0xb1/0xa40 kernel/locking/rwsem.c:1526
mmap_read_lock+0x1c/0x60 include/linux/mmap_lock.h:144
unmap_single_vma+0x2a0/0x330 mm/memory.c:1832
unmap_vmas+0x3cc/0x5f0 mm/memory.c:1904
exit_mmap+0x264/0xc80 mm/mmap.c:3412
__mmput+0x115/0x390 kernel/fork.c:1347
exit_mm+0x220/0x310 kernel/exit.c:571
do_exit+0x9b2/0x27f0 kernel/exit.c:869
do_group_exit+0x207/0x2c0 kernel/exit.c:1031
__do_sys_exit_group kernel/exit.c:1042 [inline]
__se_sys_exit_group kernel/exit.c:1040 [inline]
__x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1040
x64_sys_call+0x26c3/0x26d0 arch/x86/include/generated/asm/syscalls_64.h:232
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:0x7fd19a876a90
Code: Unable to access opcode bytes at 0x7fd19a876a66.
RSP: 002b:00007ffd90b476e8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007fd19a967860 RCX: 00007fd19a876a90
RDX: 00000000000000e7 RSI: 000000000000003c RDI: 0000000000000000
RBP: 00007fd19a967860 R08: 00007ffd90b47560 R09: 00007ffd90b47640
R10: 00007ffd90b475a0 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fd19a96b658 R15: 0000000000000001
</TASK>
mount (4518) used greatest stack depth: 23680 bytes left


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

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

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