2022-04-27 13:10:09

by syzbot

[permalink] [raw]
Subject: [syzbot] WARNING in vma_merge

Hello,

syzbot found the following issue on:

HEAD commit: f02ac5c95dfd Add linux-next specific files for 20220427
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=134114c8f00000
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

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: [email protected]

------------[ cut here ]------------
WARNING: CPU: 0 PID: 16395 at mm/mmap.c:1072 vma_merge+0x428/0x950 mm/mmap.c:1072
Modules linked in:
CPU: 0 PID: 16395 Comm: syz-executor.0 Not tainted 5.18.0-rc4-next-20220427-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:vma_merge+0x428/0x950 mm/mmap.c:1072
Code: 00 e8 5c 1f c4 ff e8 57 1f c4 ff 45 31 f6 e8 4f 1f c4 ff 4c 89 f0 48 83 c4 28 5b 5d 41 5c 41 5d 41 5e 41 5f c3 e8 38 1f c4 ff <0f> 0b e9 6c fd ff ff e8 2c 1f c4 ff 48 8d bd 88 00 00 00 48 b8 00
RSP: 0018:ffffc90002dffc90 EFLAGS: 00010293
RSP: 0018:ffffc90002dffc90 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 0000000008100077 RCX: 0000000000000000
RDX: ffff888076f91d40 RSI: ffffffff81b62968 RDI: 0000000000000003
RBP: ffff88801bea8000 R08: 0000000020600000 R09: 0000000000000000
R10: ffffffff81b626ce R11: 0000000000000000 R12: 0000000020ce2000
R13: 0000000020600000 R14: ffff8880791ba360 R15: ffff8880791ba360
FS: 0000555556995400(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020002a80 CR3: 000000003bbf8000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
userfaultfd_release+0x4c5/0x670 fs/userfaultfd.c:888
__fput+0x277/0x9d0 fs/file_table.c:317
task_work_run+0xdd/0x1a0 kernel/task_work.c:169
resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
exit_to_user_mode_loop kernel/entry/common.c:169 [inline]
exit_to_user_mode_prepare+0x23c/0x250 kernel/entry/common.c:201
__syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline]
syscall_exit_to_user_mode+0x19/0x50 kernel/entry/common.c:294
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f394ce3bd2b
Code: 0f 05 48 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 83 ec 18 89 7c 24 0c e8 63 fc ff ff 8b 7c 24 0c 41 89 c0 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 89 44 24 0c e8 a1 fc ff ff 8b 44
RSP: 002b:00007ffc0fe56030 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000005 RCX: 00007f394ce3bd2b
RDX: 00007f394cfa04b0 RSI: ffffffffffffffff RDI: 0000000000000004
RBP: 00007f394cf9d960 R08: 0000000000000000 R09: 00007f394cfa04b8
R10: 00007ffc0fe56130 R11: 0000000000000293 R12: 0000000000085752
R13: 00007ffc0fe56130 R14: 00007f394cf9bf60 R15: 0000000000000032
</TASK>


---
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 [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.


2022-04-27 13:48:45

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] WARNING in vma_merge

syzbot has found a reproducer for the following issue on:

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: [email protected]

------------[ cut here ]------------
WARNING: CPU: 0 PID: 3593 at mm/mmap.c:1072 vma_merge+0x428/0x950 mm/mmap.c:1072
Modules linked in:
CPU: 1 PID: 3593 Comm: syz-executor549 Not tainted 5.18.0-rc4-next-20220427-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:vma_merge+0x428/0x950 mm/mmap.c:1072
Code: 00 e8 5c 1f c4 ff e8 57 1f c4 ff 45 31 f6 e8 4f 1f c4 ff 4c 89 f0 48 83 c4 28 5b 5d 41 5c 41 5d 41 5e 41 5f c3 e8 38 1f c4 ff <0f> 0b e9 6c fd ff ff e8 2c 1f c4 ff 48 8d bd 88 00 00 00 48 b8 00
RSP: 0018:ffffc90002edfd10 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 0000000008102073 RCX: 0000000000000000
RDX: ffff88801d0a3a80 RSI: ffffffff81b62968 RDI: 0000000000000003
RBP: ffff88807e550bd0 R08: 0000000021001000 R09: 0000000000000000
R10: ffffffff81b626ce R11: 0000000000000000 R12: 0000555557211000
R13: 00005555571ef000 R14: ffff88807e550d80 R15: ffff88807e550d80
FS: 00005555571ef300(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00005564400b0df0 CR3: 0000000073d7f000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
mlock_fixup+0x349/0x7f0 mm/mlock.c:420
apply_mlockall_flags+0x2be/0x440 mm/mlock.c:691
__do_sys_mlockall+0x222/0x4b0 mm/mlock.c:719
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:0x7f9cdd5a1f99
Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffecfa63c98 EFLAGS: 00000246 ORIG_RAX: 0000000000000097
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f9cdd5a1f99
RDX: 00007f9cdd5a1f99 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 00007f9cdd565f80 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f9cdd566010
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
</TASK>

2022-04-27 17:47:54

by Andrew Morton

[permalink] [raw]
Subject: Re: [syzbot] WARNING in vma_merge

On Wed, 27 Apr 2022 06:15:20 -0700 syzbot <[email protected]> wrote:

> syzbot has found a reproducer for the following issue on:

Thanks.

userfaultfd_release() appears to have offended vma_merge().

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: [email protected]
>
> ------------[ 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 &&




> Modules linked in:
> CPU: 1 PID: 3593 Comm: syz-executor549 Not tainted 5.18.0-rc4-next-20220427-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> RIP: 0010:vma_merge+0x428/0x950 mm/mmap.c:1072
> Code: 00 e8 5c 1f c4 ff e8 57 1f c4 ff 45 31 f6 e8 4f 1f c4 ff 4c 89 f0 48 83 c4 28 5b 5d 41 5c 41 5d 41 5e 41 5f c3 e8 38 1f c4 ff <0f> 0b e9 6c fd ff ff e8 2c 1f c4 ff 48 8d bd 88 00 00 00 48 b8 00
> RSP: 0018:ffffc90002edfd10 EFLAGS: 00010293
> RAX: 0000000000000000 RBX: 0000000008102073 RCX: 0000000000000000
> RDX: ffff88801d0a3a80 RSI: ffffffff81b62968 RDI: 0000000000000003
> RBP: ffff88807e550bd0 R08: 0000000021001000 R09: 0000000000000000
> R10: ffffffff81b626ce R11: 0000000000000000 R12: 0000555557211000
> R13: 00005555571ef000 R14: ffff88807e550d80 R15: ffff88807e550d80
> FS: 00005555571ef300(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00005564400b0df0 CR3: 0000000073d7f000 CR4: 00000000003506e0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
> <TASK>
> mlock_fixup+0x349/0x7f0 mm/mlock.c:420
> apply_mlockall_flags+0x2be/0x440 mm/mlock.c:691
> __do_sys_mlockall+0x222/0x4b0 mm/mlock.c:719
> 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:0x7f9cdd5a1f99
> Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 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 c0 ff ff ff f7 d8 64 89 01 48
> RSP: 002b:00007ffecfa63c98 EFLAGS: 00000246 ORIG_RAX: 0000000000000097
> RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f9cdd5a1f99
> RDX: 00007f9cdd5a1f99 RSI: 0000000000000000 RDI: 0000000000000003
> RBP: 00007f9cdd565f80 R08: 0000000000000000 R09: 0000000000000000
> R10: 0000000000000000 R11: 0000000000000246 R12: 00007f9cdd566010
> R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
> </TASK>

2022-04-27 18:19:35

by Liam R. Howlett

[permalink] [raw]
Subject: Re: [syzbot] WARNING in vma_merge

* Andrew Morton <[email protected]> [220427 13:20]:
> On Wed, 27 Apr 2022 06:15:20 -0700 syzbot <[email protected]> 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: [email protected]
> >
> > ------------[ 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

2022-04-27 19:39:08

by Liam R. Howlett

[permalink] [raw]
Subject: Re: [syzbot] WARNING in vma_merge

* Liam R. Howlett <[email protected]> [220427 13:52]:
> * Andrew Morton <[email protected]> [220427 13:20]:
> > On Wed, 27 Apr 2022 06:15:20 -0700 syzbot <[email protected]> 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: [email protected]
> > >

...

>
> 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.


I was able to reproduce the issue using the config from syzkaller in my
VM and can confirm it was the apply_mlockall_flags() bug also reported
by Qian Cai [1]. The patch I sent earlier [2] fixes this issue as well.


1. https://lore.kernel.org/linux-mm/20220427161033.GA1935@qian/
2. https://lore.kernel.org/linux-mm/20220427165139.5s3qcj2u5vqrvwlc@revolver/

Thanks,
Liam

2022-04-28 05:42:47

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] WARNING in vma_merge

syzbot has bisected this issue to:

commit 80207910cd71b4e0e87140d165d82b5d3ff69e53
Author: Andrey Konovalov <[email protected]>
Date: Fri Mar 25 01:13:12 2022 +0000

kasan: move and hide kasan_save_enable/restore_multi_shot

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=16d9a4e4f00000
start commit: f02ac5c95dfd Add linux-next specific files for 20220427
git tree: linux-next
final oops: https://syzkaller.appspot.com/x/report.txt?x=15d9a4e4f00000
console output: https://syzkaller.appspot.com/x/log.txt?x=11d9a4e4f00000
kernel config: https://syzkaller.appspot.com/x/.config?x=e9256c70f586da8a
dashboard link: https://syzkaller.appspot.com/bug?extid=7728e4ab5371cebc9c00
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15f76f82f00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12b42c3cf00000

Reported-by: [email protected]
Fixes: 80207910cd71 ("kasan: move and hide kasan_save_enable/restore_multi_shot")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

2022-04-28 08:47:31

by Dmitry Vyukov

[permalink] [raw]
Subject: Re: [syzbot] WARNING in vma_merge

On Wed, 27 Apr 2022 at 21:06, Liam Howlett <[email protected]> wrote:
>
> * Liam R. Howlett <[email protected]> [220427 13:52]:
> > * Andrew Morton <[email protected]> [220427 13:20]:
> > > On Wed, 27 Apr 2022 06:15:20 -0700 syzbot <[email protected]> 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: [email protected]
> > > >
>
> ...
>
> >
> > 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.
>
>
> I was able to reproduce the issue using the config from syzkaller in my
> VM and can confirm it was the apply_mlockall_flags() bug also reported
> by Qian Cai [1]. The patch I sent earlier [2] fixes this issue as well.
>
>
> 1. https://lore.kernel.org/linux-mm/20220427161033.GA1935@qian/
> 2. https://lore.kernel.org/linux-mm/20220427165139.5s3qcj2u5vqrvwlc@revolver/
>
> Thanks,
> Liam

Let's tell syzbot about the fix:
#syz fix: mm/mlock: use maple state in apply_mlockall_flags()