Re: [syzbot] WARNING in anon_vma_name

From: syzbot
Date: Mon Nov 14 2022 - 05:55:32 EST


Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
possible deadlock in show_map_vma

============================================
WARNING: possible recursive locking detected
6.1.0-rc4-next-20221111-syzkaller-dirty #0 Not tainted
--------------------------------------------
syz-executor.0/5772 is trying to acquire lock:
ffff88807dd89b98 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock_killable include/linux/mmap_lock.h:126 [inline]
ffff88807dd89b98 (&mm->mmap_lock){++++}-{3:3}, at: show_map_vma+0x1dd/0x8a0 fs/proc/task_mmu.c:298

but task is already holding lock:
ffff88807dd89b98 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock_killable include/linux/mmap_lock.h:126 [inline]
ffff88807dd89b98 (&mm->mmap_lock){++++}-{3:3}, at: m_start+0x1d6/0x670 fs/proc/task_mmu.c:162

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

2 locks held by syz-executor.0/5772:
#0: ffff88801d4c28b8 (&p->lock){+.+.}-{3:3}, at: seq_read_iter+0xdf/0x1280 fs/seq_file.c:182
#1: ffff88807dd89b98 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock_killable include/linux/mmap_lock.h:126 [inline]
#1: ffff88807dd89b98 (&mm->mmap_lock){++++}-{3:3}, at: m_start+0x1d6/0x670 fs/proc/task_mmu.c:162

stack backtrace:
CPU: 1 PID: 5772 Comm: syz-executor.0 Not tainted 6.1.0-rc4-next-20221111-syzkaller-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
print_deadlock_bug kernel/locking/lockdep.c:2990 [inline]
check_deadlock kernel/locking/lockdep.c:3033 [inline]
validate_chain kernel/locking/lockdep.c:3818 [inline]
__lock_acquire.cold+0x116/0x3a7 kernel/locking/lockdep.c:5055
lock_acquire kernel/locking/lockdep.c:5668 [inline]
lock_acquire+0x1df/0x630 kernel/locking/lockdep.c:5633
down_read_killable+0x9b/0x490 kernel/locking/rwsem.c:1532
mmap_read_lock_killable include/linux/mmap_lock.h:126 [inline]
show_map_vma+0x1dd/0x8a0 fs/proc/task_mmu.c:298
show_smap+0xe4/0x490 fs/proc/task_mmu.c:873
traverse.part.0+0xcf/0x5f0 fs/seq_file.c:111
traverse fs/seq_file.c:101 [inline]
seq_read_iter+0x90f/0x1280 fs/seq_file.c:195
seq_read+0x16d/0x210 fs/seq_file.c:162
do_loop_readv_writev fs/read_write.c:756 [inline]
do_loop_readv_writev fs/read_write.c:743 [inline]
do_iter_read+0x4f8/0x750 fs/read_write.c:798
vfs_readv+0xe5/0x150 fs/read_write.c:916
do_preadv fs/read_write.c:1008 [inline]
__do_sys_preadv fs/read_write.c:1058 [inline]
__se_sys_preadv fs/read_write.c:1053 [inline]
__x64_sys_preadv+0x22b/0x310 fs/read_write.c:1053
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fdc27c8b639
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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:00007fdc28980168 EFLAGS: 00000246 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 00007fdc27dabf80 RCX: 00007fdc27c8b639
RDX: 0000000000000001 RSI: 00000000200006c0 RDI: 0000000000000003
RBP: 00007fdc27ce67e1 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000fffffffe R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffc20c7d9af R14: 00007fdc28980300 R15: 0000000000022000
</TASK>


Tested on:

commit: f8f60f32 Add linux-next specific files for 20221111
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
console output: https://syzkaller.appspot.com/x/log.txt?x=13a0e2f1880000
kernel config: https://syzkaller.appspot.com/x/.config?x=85ba52c07cd97289
dashboard link: https://syzkaller.appspot.com/bug?extid=62ed954113bf02c79f74
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=1069e0f1880000