[syzbot] BUG: sleeping function called from invalid context in __munlock_pagevec

From: syzbot
Date: Sat Jul 10 2021 - 18:13:56 EST


Hello,

syzbot found the following issue on:

HEAD commit: ee268dee Add linux-next specific files for 20210707
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=13ed30d2300000
kernel config: https://syzkaller.appspot.com/x/.config?x=59e1e3bbc3afca75
dashboard link: https://syzkaller.appspot.com/bug?extid=cf9c548279bff83b0c97
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17a25ee4300000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14f81928300000

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

BUG: sleeping function called from invalid context at include/linux/pagemap.h:674
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 8467, name: syz-executor631
1 lock held by syz-executor631/8467:
#0: ffff8880343e0978 (ptlock_ptr(page)#2){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:359 [inline]
#0: ffff8880343e0978 (ptlock_ptr(page)#2){+.+.}-{2:2}, at: map_pte mm/page_vma_mapped.c:52 [inline]
#0: ffff8880343e0978 (ptlock_ptr(page)#2){+.+.}-{2:2}, at: page_vma_mapped_walk+0xd87/0x24f0 mm/page_vma_mapped.c:261
Preemption disabled at:
[<0000000000000000>] 0x0
CPU: 0 PID: 8467 Comm: syz-executor631 Not tainted 5.13.0-next-20210707-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:105
___might_sleep.cold+0x1f1/0x237 kernel/sched/core.c:9171
lock_page include/linux/pagemap.h:674 [inline]
__munlock_pagevec+0xa22/0x2340 mm/mlock.c:314
munlock_vma_pages_range+0x9d7/0xf00 mm/mlock.c:475
munlock_vma_pages_all mm/internal.h:354 [inline]
unlock_range mm/mmap.c:2811 [inline]
exit_mmap+0x47a/0x620 mm/mmap.c:3188
__mmput+0x122/0x470 kernel/fork.c:1152
mmput+0x58/0x60 kernel/fork.c:1173
exit_mm kernel/exit.c:501 [inline]
do_exit+0xae2/0x2a60 kernel/exit.c:812
do_group_exit+0x125/0x310 kernel/exit.c:922
__do_sys_exit_group kernel/exit.c:933 [inline]
__se_sys_exit_group kernel/exit.c:931 [inline]
__x64_sys_exit_group+0x3a/0x50 kernel/exit.c:931
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+0x44/0xae
RIP: 0033:0x43e969
Code: Unable to access opcode bytes at RIP 0x43e93f.
RSP: 002b:00007ffce2d3a7a8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00000000004b02f0 RCX: 000000000043e969
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
RBP: 0000000000000000 R08: ffffffffffffffc0 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000004b02f0
R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000001

=============================
[ BUG: Invalid wait context ]
5.13.0-next-20210707-syzkaller #0 Tainted: G W
-----------------------------
syz-executor631/8467 is trying to lock:
ffff888035ea6000 (&mapping->i_mmap_rwsem){++++}-{3:3}, at: i_mmap_lock_read include/linux/fs.h:514 [inline]
ffff888035ea6000 (&mapping->i_mmap_rwsem){++++}-{3:3}, at: rmap_walk_file+0x52f/0x710 mm/rmap.c:2337
other info that might help us debug this:
context-{4:4}
1 lock held by syz-executor631/8467:
#0: ffff8880343e0978 (ptlock_ptr(page)#2){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:359 [inline]
#0: ffff8880343e0978 (ptlock_ptr(page)#2){+.+.}-{2:2}, at: map_pte mm/page_vma_mapped.c:52 [inline]
#0: ffff8880343e0978 (ptlock_ptr(page)#2){+.+.}-{2:2}, at: page_vma_mapped_walk+0xd87/0x24f0 mm/page_vma_mapped.c:261
stack backtrace:
CPU: 0 PID: 8467 Comm: syz-executor631 Tainted: G W 5.13.0-next-20210707-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:105
print_lock_invalid_wait_context kernel/locking/lockdep.c:4666 [inline]
check_wait_context kernel/locking/lockdep.c:4727 [inline]
__lock_acquire.cold+0x213/0x3ab kernel/locking/lockdep.c:4965
lock_acquire kernel/locking/lockdep.c:5625 [inline]
lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5590
down_read+0x9a/0x440 kernel/locking/rwsem.c:1353
i_mmap_lock_read include/linux/fs.h:514 [inline]
rmap_walk_file+0x52f/0x710 mm/rmap.c:2337
rmap_walk+0x10d/0x190 mm/rmap.c:2366
page_mlock+0x448/0x650 mm/rmap.c:2029
__munlock_isolated_page+0x88/0x410 mm/mlock.c:122
__munlock_pagevec+0xd7f/0x2340 mm/mlock.c:322
munlock_vma_pages_range+0x9d7/0xf00 mm/mlock.c:475
munlock_vma_pages_all mm/internal.h:354 [inline]
unlock_range mm/mmap.c:2811 [inline]
exit_mmap+0x47a/0x620 mm/mmap.c:3188
__mmput+0x122/0x470 kernel/fork.c:1152
mmput+0x58/0x60 kernel/fork.c:1173
exit_mm kernel/exit.c:501 [inline]
do_exit+0xae2/0x2a60 kernel/exit.c:812
do_group_exit+0x125/0x310 kernel/exit.c:922
__do_sys_exit_group kernel/exit.c:933 [inline]
__se_sys_exit_group kernel/exit.c:931 [inline]
__x64_sys_exit_group+0x3a/0x50 kernel/exit.c:931
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+0x44/0xae
RIP: 0033:0x43e969
Code: Unable to access opcode bytes at RIP 0x43e93f.
RSP: 002b:00007ffce2d3a7a8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00000000004b02f0 RCX: 000000000043e969
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
RBP: 0000000000000000 R08: ffffffffffffffc0 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000004b02f0
R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000001


---
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.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches