possible deadlock in __mmu_notifier_invalidate_range_end

From: syzbot
Date: Fri Sep 06 2019 - 13:08:13 EST


Hello,

syzbot found the following crash on:

HEAD commit: 6d028043 Add linux-next specific files for 20190830
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=16cbf22a600000
kernel config: https://syzkaller.appspot.com/x/.config?x=82a6bec43ab0cb69
dashboard link: https://syzkaller.appspot.com/bug?extid=aaedc50d99a03250fe1f
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15269876600000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12685092600000

The bug was bisected to:

commit e58b341134ca751d9c12bacded12a8b4dd51368d
Author: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx>
Date: Fri Aug 30 09:42:14 2019 +0000

Merge remote-tracking branch 'hmm/hmm'

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=11ea65ea600000
final crash: https://syzkaller.appspot.com/x/report.txt?x=13ea65ea600000
console output: https://syzkaller.appspot.com/x/log.txt?x=15ea65ea600000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+aaedc50d99a03250fe1f@xxxxxxxxxxxxxxxxxxxxxxxxx
Fixes: e58b341134ca ("Merge remote-tracking branch 'hmm/hmm'")

============================================
WARNING: possible recursive locking detected
5.3.0-rc6-next-20190830 #75 Not tainted
--------------------------------------------
oom_reaper/1065 is trying to acquire lock:
ffffffff8904ff60 (mmu_notifier_invalidate_range_start){+.+.}, at: __mmu_notifier_invalidate_range_end+0x0/0x360 mm/mmu_notifier.c:169

but task is already holding lock:
ffffffff8904ff60 (mmu_notifier_invalidate_range_start){+.+.}, at: __oom_reap_task_mm+0x196/0x490 mm/oom_kill.c:542

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

CPU0
----
lock(mmu_notifier_invalidate_range_start);
lock(mmu_notifier_invalidate_range_start);

*** DEADLOCK ***

May be due to missing lock nesting notation

2 locks held by oom_reaper/1065:
#0: ffff888094ad3990 (&mm->mmap_sem#2){++++}, at: oom_reap_task_mm mm/oom_kill.c:570 [inline]
#0: ffff888094ad3990 (&mm->mmap_sem#2){++++}, at: oom_reap_task mm/oom_kill.c:613 [inline]
#0: ffff888094ad3990 (&mm->mmap_sem#2){++++}, at: oom_reaper+0x3a7/0x1320 mm/oom_kill.c:651
#1: ffffffff8904ff60 (mmu_notifier_invalidate_range_start){+.+.}, at: __oom_reap_task_mm+0x196/0x490 mm/oom_kill.c:542

stack backtrace:
CPU: 1 PID: 1065 Comm: oom_reaper Not tainted 5.3.0-rc6-next-20190830 #75
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x172/0x1f0 lib/dump_stack.c:113
print_deadlock_bug kernel/locking/lockdep.c:2371 [inline]
check_deadlock kernel/locking/lockdep.c:2412 [inline]
validate_chain kernel/locking/lockdep.c:2955 [inline]
__lock_acquire.cold+0x15d/0x385 kernel/locking/lockdep.c:3955
lock_acquire+0x190/0x410 kernel/locking/lockdep.c:4487
__mmu_notifier_invalidate_range_end+0x3c/0x360 mm/mmu_notifier.c:193
mmu_notifier_invalidate_range_end include/linux/mmu_notifier.h:375 [inline]
__oom_reap_task_mm+0x3fa/0x490 mm/oom_kill.c:552
oom_reap_task_mm mm/oom_kill.c:589 [inline]
oom_reap_task mm/oom_kill.c:613 [inline]
oom_reaper+0x2b2/0x1320 mm/oom_kill.c:651
kthread+0x361/0x430 kernel/kthread.c:255
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
oom_reaper: reaped process 10145 (syz-executor282), now anon-rss:16480kB, file-rss:872kB, shmem-rss:0kB
oom_reaper: reaped process 10144 (syz-executor282), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
oom_reaper: reaped process 10158 (syz-executor282), now anon-rss:16824kB, file-rss:872kB, shmem-rss:0kB
oom_reaper: reaped process 10187 (syz-executor282), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
oom_reaper: reaped process 10173 (syz-executor282), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
oom_reaper: reaped process 10139 (syz-executor282), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB


---
This bug 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@xxxxxxxxxxxxxxxxx

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches