Re: [syzbot] WARNING in vma_merge

From: Liam Howlett
Date: Wed Apr 27 2022 - 13:52:41 EST


* Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> [220427 13:20]:
> On Wed, 27 Apr 2022 06:15:20 -0700 syzbot <syzbot+7728e4ab5371cebc9c00@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> > syzbot has found a reproducer for the following issue on:
>
> Thanks.
>
> userfaultfd_release() appears to have offended vma_merge().

Potentially apply_mlockall_flags() and not userfaultfd_release(). There
is a potential that the vma iterator is stale if a split/merge succeeds,
although KASAN should pick this up and KASAN is active according to the
config below. I've sent a patch for the mlockall issue after Qian Cai's
reported it to linux-mm.

>
> I'm not seeing any changes in that area from Peter, but Liam's
> mapletree work changed things around a bit. Gents, could you please
> take a look?
>
>
> > HEAD commit: f02ac5c95dfd Add linux-next specific files for 20220427
> > git tree: linux-next
> > console output: https://syzkaller.appspot.com/x/log.txt?x=105a33a2f00000
> > kernel config: https://syzkaller.appspot.com/x/.config?x=e9256c70f586da8a
> > dashboard link: https://syzkaller.appspot.com/bug?extid=7728e4ab5371cebc9c00
> > compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15f76f82f00000
> > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12b42c3cf00000
> >
> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+7728e4ab5371cebc9c00@xxxxxxxxxxxxxxxxxxxxxxxxx
> >
> > ------------[ cut here ]------------
> > WARNING: CPU: 0 PID: 3593 at mm/mmap.c:1072 vma_merge+0x428/0x950 mm/mmap.c:1072
>
> I assume this is
>
> VM_WARN_ON(area && end > area->vm_end);
>
> But lines change around a lot. It would be great if the script which
> generates these reports could quote the code around the indicated file
> and line. Like:
>
> next = find_vma(mm, prev ? prev->vm_end : 0);
> area = next;
> if (area && area->vm_end == end) /* cases 6, 7, 8 */
> next = find_vma(mm, next->vm_end);
>
> /* verify some invariant that must be enforced by the caller */
> VM_WARN_ON(prev && addr <= prev->vm_start);
> --> VM_WARN_ON(area && end > area->vm_end);
> VM_WARN_ON(addr >= end);
>
> /*
> * Can it merge with the predecessor?
> */
> if (prev && prev->vm_end == addr &&


That is the correct line according to the git tree and HEAD commit
listed above.

I cannot get this issue to trigger with the given tree and git repo with
my config. I will try again with the kernel config above.

Thanks,
Liam