Re: kernel BUG at mm/mmap.c:LINE!

From: Souptick Joarder
Date: Wed Sep 30 2020 - 22:58:13 EST


On Fri, Sep 4, 2020 at 12:39 AM syzbot
<syzbot+721b657f8f01708b291b@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 1127b219 Merge tag 'fallthrough-fixes-5.9-rc3' of git://gi..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=136d098e900000
> kernel config: https://syzkaller.appspot.com/x/.config?x=978db74cb30aa994
> dashboard link: https://syzkaller.appspot.com/bug?extid=721b657f8f01708b291b
> compiler: gcc (GCC) 10.1.0-syz 20200507
>
> Unfortunately, I don't have any reproducer for this issue yet.
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+721b657f8f01708b291b@xxxxxxxxxxxxxxxxxxxxxxxxx
>
> start_brk 558decf56000 brk 558ded160000 start_stack 7ffd20847a70
> arg_start 7ffd20847e89 arg_end 7ffd20847ea4 env_start 7ffd20847ea4 env_end 7ffd20847fdd
> binfmt ffffffff89cdcb60 flags 200cd core_state 0000000000000000
> ioctx_table 0000000000000000
> ------------[ cut here ]------------
> kernel BUG at mm/mmap.c:427!
> invalid opcode: 0000 [#1] PREEMPT SMP KASAN
> CPU: 0 PID: 28867 Comm: systemd-udevd Not tainted 5.9.0-rc2-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> RIP: 0010:validate_mm+0x617/0x800 mm/mmap.c:427
> Code: cf f5 cd ff 44 89 e6 bf ff ff ff ff e8 42 f2 cd ff 41 83 fc ff 0f 85 86 1b 01 00 e8 b3 f5 cd ff 48 8b 7c 24 18 e8 d9 59 fc ff <0f> 0b e8 a2 f5 cd ff 48 8b 54 24 28 48 b8 00 00 00 00 00 fc ff df
> RSP: 0018:ffffc90015d6fd98 EFLAGS: 00010286
> RAX: 000000000000038d RBX: 000000000000004f RCX: 0000000000000000
> RDX: ffff8880475ac380 RSI: ffffffff815dafc7 RDI: fffff52002badf52
> RBP: 0000000000000000 R08: 000000000000038d R09: ffff8880ae6318e7
> R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000001
> R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
> FS: 00007fb1b935a8c0(0000) GS:ffff8880ae600000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007ffd20959990 CR3: 0000000217691000 CR4: 00000000001526f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
> remove_vma_list mm/mmap.c:2616 [inline]
> __do_munmap+0x899/0x1170 mm/mmap.c:2869
> __vm_munmap+0xe6/0x180 mm/mmap.c:2889
> __do_sys_munmap mm/mmap.c:2915 [inline]
> __se_sys_munmap mm/mmap.c:2911 [inline]
> __x64_sys_munmap+0x62/0x80 mm/mmap.c:2911
> do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
> entry_SYSCALL_64_after_hwframe+0x44/0xa9
> RIP: 0033:0x7fb1b81d66e7
> Code: c7 c0 ff ff ff ff eb 8d 48 8b 15 ac 47 2b 00 f7 d8 64 89 02 e9 5b ff ff ff 66 2e 0f 1f 84 00 00 00 00 00 b8 0b 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 81 47 2b 00 f7 d8 64 89 01 48
> RSP: 002b:00007ffd20846cd8 EFLAGS: 00000206 ORIG_RAX: 000000000000000b
> RAX: ffffffffffffffda RBX: 0000558decf56100 RCX: 00007fb1b81d66e7
> RDX: 0000000000000080 RSI: 000000000080ccec RDI: 00007fb1b7064000
> RBP: 0000558debda4d18 R08: 0000558decf6a3c0 R09: 0000000000000000
> R10: 00000000ffffffff R11: 0000000000000206 R12: 0000558decf560e0
> R13: 0000000000000000 R14: 0000000000000003 R15: 000000000000000e
> Modules linked in:
> ---[ end trace 76a00ebdfa09cc52 ]---
> RIP: 0010:validate_mm+0x617/0x800 mm/mmap.c:427
> Code: cf f5 cd ff 44 89 e6 bf ff ff ff ff e8 42 f2 cd ff 41 83 fc ff 0f 85 86 1b 01 00 e8 b3 f5 cd ff 48 8b 7c 24 18 e8 d9 59 fc ff <0f> 0b e8 a2 f5 cd ff 48 8b 54 24 28 48 b8 00 00 00 00 00 fc ff df
> RSP: 0018:ffffc90015d6fd98 EFLAGS: 00010286
> RAX: 000000000000038d RBX: 000000000000004f RCX: 0000000000000000
> RDX: ffff8880475ac380 RSI: ffffffff815dafc7 RDI: fffff52002badf52
> RBP: 0000000000000000 R08: 000000000000038d R09: ffff8880ae6318e7
> R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000001
> R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
> FS: 00007fb1b935a8c0(0000) GS:ffff8880ae600000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007fad09fed000 CR3: 0000000217691000 CR4: 00000000001526f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
>
>

CONFIG_DEBUG_VM_RB=y is set.

[ 1882.597004][T28867] mmap: backwards 1, forwards 3
[ 1882.605532][T28867] mm ffff88804eeff640 mmap ffff888094849318
seqnum 1 task_size 140737488351232

Looks like we hit panic due to below code.

static int browse_rb(struct mm_struct *mm) {
...
if (i != j) {
pr_emerg("backwards %d, forwards %d\n", j, i);
bug = 1;
}
...
}