All of lore.kernel.org
 help / color / mirror / Atom feed
* [syzbot] WARNING in kvm_mmu_notifier_invalidate_range_start (2)
@ 2022-03-21 10:25 ` syzbot
  0 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2022-03-21 10:25 UTC (permalink / raw)
  To: agordeev, aleksandar.qemu.devel, alexandru.elisei, benh,
	borntraeger, bp, catalin.marinas, chenhuacai, dave.hansen, david,
	dja, frankja, gor, hca, hpa, imbrenda, james.morse, jmattson,
	joro, kvm, kvmarm, linux-arm-kernel, linux-kernel, linux-mips,
	linux-s390, linuxppc-dev, lukas.bulwahn, maciej.szmigiero, maz,
	mingo, mpe, paulus, pbonzini, seanjc, suzuki.poulose,
	syzkaller-bugs, tglx, tsbogend, vkuznets, wanpengli, will, x86

Hello,

syzbot found the following issue on:

HEAD commit:    56e337f2cf13 Revert "gpio: Revert regression in sysfs-gpio..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=13821b8d700000
kernel config:  https://syzkaller.appspot.com/x/.config?x=d35f9bc6884af6c9
dashboard link: https://syzkaller.appspot.com/bug?extid=6bde52d89cfdf9f61425
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=12a2d0a9700000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=13d34fd9700000

The issue was bisected to:

commit ed922739c9199bf515a3e7fec3e319ce1edeef2a
Author: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Date:   Mon Dec 6 19:54:28 2021 +0000

    KVM: Use interval tree to do fast hva lookup in memslots

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=142aa59d700000
final oops:     https://syzkaller.appspot.com/x/report.txt?x=162aa59d700000
console output: https://syzkaller.appspot.com/x/log.txt?x=122aa59d700000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+6bde52d89cfdf9f61425@syzkaller.appspotmail.com
Fixes: ed922739c919 ("KVM: Use interval tree to do fast hva lookup in memslots")

------------[ cut here ]------------
WARNING: CPU: 0 PID: 3599 at arch/x86/kvm/../../../virt/kvm/kvm_main.c:529 __kvm_handle_hva_range arch/x86/kvm/../../../virt/kvm/kvm_main.c:529 [inline]
WARNING: CPU: 0 PID: 3599 at arch/x86/kvm/../../../virt/kvm/kvm_main.c:529 kvm_mmu_notifier_invalidate_range_start+0x97a/0xb20 arch/x86/kvm/../../../virt/kvm/kvm_main.c:714
Modules linked in:
CPU: 0 PID: 3599 Comm: syz-executor221 Not tainted 5.17.0-rc8-syzkaller-00003-g56e337f2cf13 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:__kvm_handle_hva_range arch/x86/kvm/../../../virt/kvm/kvm_main.c:529 [inline]
RIP: 0010:kvm_mmu_notifier_invalidate_range_start+0x97a/0xb20 arch/x86/kvm/../../../virt/kvm/kvm_main.c:714
Code: 00 48 c7 c2 60 0c a2 89 be b9 01 00 00 48 c7 c7 c0 10 a2 89 c6 05 ed 71 76 0c 01 e8 79 84 ff 07 e9 73 ff ff ff e8 b6 cd 6f 00 <0f> 0b e9 88 fc ff ff e8 aa cd 6f 00 0f 0b e9 58 fc ff ff e8 9e cd
RSP: 0018:ffffc90001caf948 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 000000002000d000 RCX: 0000000000000000
RDX: ffff888020d83a00 RSI: ffffffff8108f27a RDI: 0000000000000003
RBP: ffffc90002b76290 R08: 000000002000d000 R09: ffffc90002b762e3
R10: ffffffff8108eb1c R11: 0000000000000001 R12: ffffc90002b7f240
R13: ffffc90002b75000 R14: ffffc90001cafc18 R15: 000000002000d000
FS:  0000555555a55300(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020000088 CR3: 0000000074ce9000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 mn_hlist_invalidate_range_start mm/mmu_notifier.c:493 [inline]
 __mmu_notifier_invalidate_range_start+0x2ff/0x800 mm/mmu_notifier.c:548
 mmu_notifier_invalidate_range_start include/linux/mmu_notifier.h:459 [inline]
 move_page_tables+0x2642/0x2d20 mm/mremap.c:498
 move_vma+0x48c/0xf40 mm/mremap.c:629
 mremap_to mm/mremap.c:862 [inline]
 __do_sys_mremap+0xf01/0x1560 mm/mremap.c:972
 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:0x7f11faab5089
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:00007ffc17608428 EFLAGS: 00000246 ORIG_RAX: 0000000000000019
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f11faab5089
RDX: 0000000000001000 RSI: fffffffffffffe74 RDI: 000000002000d000
RBP: 00007f11faa79070 R08: 0000000020007000 R09: 0000000000000000
R10: 0000000000000003 R11: 0000000000000246 R12: 00007f11faa79100
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </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 syzkaller@googlegroups.com.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [syzbot] WARNING in kvm_mmu_notifier_invalidate_range_start (2)
@ 2022-03-21 10:25 ` syzbot
  0 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2022-03-21 10:25 UTC (permalink / raw)
  To: agordeev, aleksandar.qemu.devel, alexandru.elisei, benh,
	borntraeger, bp, catalin.marinas, chenhuacai, dave.hansen, david,
	dja, frankja, gor, hca, hpa, imbrenda, james.morse, jmattson,
	joro, kvm, kvmarm, linux-arm-kernel, linux-kernel, linux-mips,
	linux-s390, linuxppc-dev, lukas.bulwahn, maciej.szmigiero, maz,
	mingo, mpe, paulus, pbonzini, seanjc, suzuki.poulose,
	syzkaller-bugs, tglx, tsbogend, vkuznets, wanpengli, will, x86

Hello,

syzbot found the following issue on:

HEAD commit:    56e337f2cf13 Revert "gpio: Revert regression in sysfs-gpio..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=13821b8d700000
kernel config:  https://syzkaller.appspot.com/x/.config?x=d35f9bc6884af6c9
dashboard link: https://syzkaller.appspot.com/bug?extid=6bde52d89cfdf9f61425
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=12a2d0a9700000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=13d34fd9700000

The issue was bisected to:

commit ed922739c9199bf515a3e7fec3e319ce1edeef2a
Author: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Date:   Mon Dec 6 19:54:28 2021 +0000

    KVM: Use interval tree to do fast hva lookup in memslots

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=142aa59d700000
final oops:     https://syzkaller.appspot.com/x/report.txt?x=162aa59d700000
console output: https://syzkaller.appspot.com/x/log.txt?x=122aa59d700000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+6bde52d89cfdf9f61425@syzkaller.appspotmail.com
Fixes: ed922739c919 ("KVM: Use interval tree to do fast hva lookup in memslots")

------------[ cut here ]------------
WARNING: CPU: 0 PID: 3599 at arch/x86/kvm/../../../virt/kvm/kvm_main.c:529 __kvm_handle_hva_range arch/x86/kvm/../../../virt/kvm/kvm_main.c:529 [inline]
WARNING: CPU: 0 PID: 3599 at arch/x86/kvm/../../../virt/kvm/kvm_main.c:529 kvm_mmu_notifier_invalidate_range_start+0x97a/0xb20 arch/x86/kvm/../../../virt/kvm/kvm_main.c:714
Modules linked in:
CPU: 0 PID: 3599 Comm: syz-executor221 Not tainted 5.17.0-rc8-syzkaller-00003-g56e337f2cf13 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:__kvm_handle_hva_range arch/x86/kvm/../../../virt/kvm/kvm_main.c:529 [inline]
RIP: 0010:kvm_mmu_notifier_invalidate_range_start+0x97a/0xb20 arch/x86/kvm/../../../virt/kvm/kvm_main.c:714
Code: 00 48 c7 c2 60 0c a2 89 be b9 01 00 00 48 c7 c7 c0 10 a2 89 c6 05 ed 71 76 0c 01 e8 79 84 ff 07 e9 73 ff ff ff e8 b6 cd 6f 00 <0f> 0b e9 88 fc ff ff e8 aa cd 6f 00 0f 0b e9 58 fc ff ff e8 9e cd
RSP: 0018:ffffc90001caf948 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 000000002000d000 RCX: 0000000000000000
RDX: ffff888020d83a00 RSI: ffffffff8108f27a RDI: 0000000000000003
RBP: ffffc90002b76290 R08: 000000002000d000 R09: ffffc90002b762e3
R10: ffffffff8108eb1c R11: 0000000000000001 R12: ffffc90002b7f240
R13: ffffc90002b75000 R14: ffffc90001cafc18 R15: 000000002000d000
FS:  0000555555a55300(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020000088 CR3: 0000000074ce9000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 mn_hlist_invalidate_range_start mm/mmu_notifier.c:493 [inline]
 __mmu_notifier_invalidate_range_start+0x2ff/0x800 mm/mmu_notifier.c:548
 mmu_notifier_invalidate_range_start include/linux/mmu_notifier.h:459 [inline]
 move_page_tables+0x2642/0x2d20 mm/mremap.c:498
 move_vma+0x48c/0xf40 mm/mremap.c:629
 mremap_to mm/mremap.c:862 [inline]
 __do_sys_mremap+0xf01/0x1560 mm/mremap.c:972
 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:0x7f11faab5089
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:00007ffc17608428 EFLAGS: 00000246 ORIG_RAX: 0000000000000019
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f11faab5089
RDX: 0000000000001000 RSI: fffffffffffffe74 RDI: 000000002000d000
RBP: 00007f11faa79070 R08: 0000000020007000 R09: 0000000000000000
R10: 0000000000000003 R11: 0000000000000246 R12: 00007f11faa79100
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </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 syzkaller@googlegroups.com.

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [syzbot] WARNING in kvm_mmu_notifier_invalidate_range_start (2)
@ 2022-03-21 10:25 ` syzbot
  0 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2022-03-21 10:25 UTC (permalink / raw)
  To: agordeev, aleksandar.qemu.devel, alexandru.elisei, benh,
	borntraeger, bp, catalin.marinas, chenhuacai, dave.hansen, david,
	dja, frankja, gor, hca, hpa, imbrenda, james.morse, jmattson,
	joro, kvm, kvmarm, linux-arm-kernel, linux-kernel, linux-mips,
	linux-s390, linuxppc-dev, lukas.bulwahn, maciej.szmigiero, maz,
	mingo, mpe, paulus, pbonzini, seanjc, suzuki.poulose,
	syzkaller-bugs, tglx, tsbogend, vkuznets, wanpengli, will, x86

Hello,

syzbot found the following issue on:

HEAD commit:    56e337f2cf13 Revert "gpio: Revert regression in sysfs-gpio..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=13821b8d700000
kernel config:  https://syzkaller.appspot.com/x/.config?x=d35f9bc6884af6c9
dashboard link: https://syzkaller.appspot.com/bug?extid=6bde52d89cfdf9f61425
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=12a2d0a9700000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=13d34fd9700000

The issue was bisected to:

commit ed922739c9199bf515a3e7fec3e319ce1edeef2a
Author: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Date:   Mon Dec 6 19:54:28 2021 +0000

    KVM: Use interval tree to do fast hva lookup in memslots

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=142aa59d700000
final oops:     https://syzkaller.appspot.com/x/report.txt?x=162aa59d700000
console output: https://syzkaller.appspot.com/x/log.txt?x=122aa59d700000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+6bde52d89cfdf9f61425@syzkaller.appspotmail.com
Fixes: ed922739c919 ("KVM: Use interval tree to do fast hva lookup in memslots")

------------[ cut here ]------------
WARNING: CPU: 0 PID: 3599 at arch/x86/kvm/../../../virt/kvm/kvm_main.c:529 __kvm_handle_hva_range arch/x86/kvm/../../../virt/kvm/kvm_main.c:529 [inline]
WARNING: CPU: 0 PID: 3599 at arch/x86/kvm/../../../virt/kvm/kvm_main.c:529 kvm_mmu_notifier_invalidate_range_start+0x97a/0xb20 arch/x86/kvm/../../../virt/kvm/kvm_main.c:714
Modules linked in:
CPU: 0 PID: 3599 Comm: syz-executor221 Not tainted 5.17.0-rc8-syzkaller-00003-g56e337f2cf13 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:__kvm_handle_hva_range arch/x86/kvm/../../../virt/kvm/kvm_main.c:529 [inline]
RIP: 0010:kvm_mmu_notifier_invalidate_range_start+0x97a/0xb20 arch/x86/kvm/../../../virt/kvm/kvm_main.c:714
Code: 00 48 c7 c2 60 0c a2 89 be b9 01 00 00 48 c7 c7 c0 10 a2 89 c6 05 ed 71 76 0c 01 e8 79 84 ff 07 e9 73 ff ff ff e8 b6 cd 6f 00 <0f> 0b e9 88 fc ff ff e8 aa cd 6f 00 0f 0b e9 58 fc ff ff e8 9e cd
RSP: 0018:ffffc90001caf948 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 000000002000d000 RCX: 0000000000000000
RDX: ffff888020d83a00 RSI: ffffffff8108f27a RDI: 0000000000000003
RBP: ffffc90002b76290 R08: 000000002000d000 R09: ffffc90002b762e3
R10: ffffffff8108eb1c R11: 0000000000000001 R12: ffffc90002b7f240
R13: ffffc90002b75000 R14: ffffc90001cafc18 R15: 000000002000d000
FS:  0000555555a55300(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020000088 CR3: 0000000074ce9000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 mn_hlist_invalidate_range_start mm/mmu_notifier.c:493 [inline]
 __mmu_notifier_invalidate_range_start+0x2ff/0x800 mm/mmu_notifier.c:548
 mmu_notifier_invalidate_range_start include/linux/mmu_notifier.h:459 [inline]
 move_page_tables+0x2642/0x2d20 mm/mremap.c:498
 move_vma+0x48c/0xf40 mm/mremap.c:629
 mremap_to mm/mremap.c:862 [inline]
 __do_sys_mremap+0xf01/0x1560 mm/mremap.c:972
 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:0x7f11faab5089
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:00007ffc17608428 EFLAGS: 00000246 ORIG_RAX: 0000000000000019
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f11faab5089
RDX: 0000000000001000 RSI: fffffffffffffe74 RDI: 000000002000d000
RBP: 00007f11faa79070 R08: 0000000020007000 R09: 0000000000000000
R10: 0000000000000003 R11: 0000000000000246 R12: 00007f11faa79100
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </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 syzkaller@googlegroups.com.

syzbot will keep track of this issue. 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 issue, for details see:
https://goo.gl/tpsmEJ#testing-patches
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [syzbot] WARNING in kvm_mmu_notifier_invalidate_range_start (2)
  2022-03-21 10:25 ` syzbot
  (?)
  (?)
@ 2022-03-21 11:01 ` Paolo Bonzini
  2022-03-21 13:42   ` Maciej S. Szmigiero
  -1 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2022-03-21 11:01 UTC (permalink / raw)
  To: syzbot, david, frankja, imbrenda, kvm, linux-kernel,
	maciej.szmigiero, seanjc, syzkaller-bugs, vkuznets, wanpengli,
	will, Linux-MM, Andrew Morton

On 3/21/22 11:25, syzbot wrote:
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=12a2d0a9700000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=13d34fd9700000
> 
> The issue was bisected to:
> 
> commit ed922739c9199bf515a3e7fec3e319ce1edeef2a
> Author: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
> Date:   Mon Dec 6 19:54:28 2021 +0000
> 
>      KVM: Use interval tree to do fast hva lookup in memslots
> 
> bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=142aa59d700000
> final oops:     https://syzkaller.appspot.com/x/report.txt?x=162aa59d700000
> console output: https://syzkaller.appspot.com/x/log.txt?x=122aa59d700000

It bisects here just because the patch introduces the warning; the issue 
is a mmu_notifier_invalidate_range_start with an empty range.  The 
offending system call

mremap(&(0x7f000000d000/0x2000)=nil, 0xfffffffffffffe74, 0x1000, 0x3, 
&(0x7f0000007000/0x1000)=nil)

really means old_len == 0 (it's page-aligned at the beginning of 
sys_mremap), and flags includes MREMAP_FIXED so it goes down to 
mremap_to and from there to move_page_tables.  No function on this path 
attempts to special case old_len == 0, the immediate fix would be

diff --git a/mm/mremap.c b/mm/mremap.c
index 002eec83e91e..0e175aef536e 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -486,6 +486,9 @@ unsigned long move_page_tables(struct vm_area_struct
  	pmd_t *old_pmd, *new_pmd;
  	pud_t *old_pud, *new_pud;

+	if (!len)
+		return 0;
+
  	old_end = old_addr + len;
  	flush_cache_range(vma, old_addr, old_end);

but there are several other ways to fix this elsewhere in the call chain:

- check for old_len == 0 somewhere in mremap_to

- skip the call in __mmu_notifier_invalidate_range_start and 
__mmu_notifier_invalidate_range_end, if people agree not to play 
whack-a-mole with the callers of mmu_notifier_invalidate_range_*.

- remove the warning in KVM

Thanks,

Paolo


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [syzbot] WARNING in kvm_mmu_notifier_invalidate_range_start (2)
  2022-03-21 11:01 ` Paolo Bonzini
@ 2022-03-21 13:42   ` Maciej S. Szmigiero
  2022-03-28 15:22     ` Sean Christopherson
  0 siblings, 1 reply; 6+ messages in thread
From: Maciej S. Szmigiero @ 2022-03-21 13:42 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: syzbot, david, frankja, imbrenda, kvm, linux-kernel, seanjc,
	syzkaller-bugs, vkuznets, wanpengli, will, Linux-MM,
	Andrew Morton

On 21.03.2022 12:01, Paolo Bonzini wrote:
> On 3/21/22 11:25, syzbot wrote:
>> syz repro:      https://urldefense.com/v3/__https://syzkaller.appspot.com/x/repro.syz?x=12a2d0a9700000__;!!ACWV5N9M2RV99hQ!bJGc10O9acwj6GeDIyIdP0zHAuWUpAyb7E4gom6naJO0VKxLGw2oijJnPqByG7ye0Uq2ZA$ C reproducer:   https://urldefense.com/v3/__https://syzkaller.appspot.com/x/repro.c?x=13d34fd9700000__;!!ACWV5N9M2RV99hQ!bJGc10O9acwj6GeDIyIdP0zHAuWUpAyb7E4gom6naJO0VKxLGw2oijJnPqByG7xoEv26SQ$
>> The issue was bisected to:
>>
>> commit ed922739c9199bf515a3e7fec3e319ce1edeef2a
>> Author: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
>> Date:   Mon Dec 6 19:54:28 2021 +0000
>>
>>      KVM: Use interval tree to do fast hva lookup in memslots
>>
>> bisection log:  https://urldefense.com/v3/__https://syzkaller.appspot.com/x/bisect.txt?x=142aa59d700000__;!!ACWV5N9M2RV99hQ!bJGc10O9acwj6GeDIyIdP0zHAuWUpAyb7E4gom6naJO0VKxLGw2oijJnPqByG7xEhtZ-FQ$ final oops:     https://urldefense.com/v3/__https://syzkaller.appspot.com/x/report.txt?x=162aa59d700000__;!!ACWV5N9M2RV99hQ!bJGc10O9acwj6GeDIyIdP0zHAuWUpAyb7E4gom6naJO0VKxLGw2oijJnPqByG7zcn2K3LQ$ console output: https://urldefense.com/v3/__https://syzkaller.appspot.com/x/log.txt?x=122aa59d700000__;!!ACWV5N9M2RV99hQ!bJGc10O9acwj6GeDIyIdP0zHAuWUpAyb7E4gom6naJO0VKxLGw2oijJnPqByG7wzducgVQ$ 
> 
> It bisects here just because the patch introduces the warning; the issue is a mmu_notifier_invalidate_range_start with an empty range.  The offending system call
> 
> mremap(&(0x7f000000d000/0x2000)=nil, 0xfffffffffffffe74, 0x1000, 0x3, &(0x7f0000007000/0x1000)=nil)
> 
> really means old_len == 0 (it's page-aligned at the beginning of sys_mremap), and flags includes MREMAP_FIXED so it goes down to mremap_to and from there to move_page_tables.  No function on this path attempts to special case old_len == 0, the immediate fix would be
> 
> diff --git a/mm/mremap.c b/mm/mremap.c
> index 002eec83e91e..0e175aef536e 100644
> --- a/mm/mremap.c
> +++ b/mm/mremap.c
> @@ -486,6 +486,9 @@ unsigned long move_page_tables(struct vm_area_struct
>       pmd_t *old_pmd, *new_pmd;
>       pud_t *old_pud, *new_pud;
> 
> +    if (!len)
> +        return 0;
> +
>       old_end = old_addr + len;
>       flush_cache_range(vma, old_addr, old_end);
> 
> but there are several other ways to fix this elsewhere in the call chain:
> 
> - check for old_len == 0 somewhere in mremap_to
> 
> - skip the call in __mmu_notifier_invalidate_range_start and __mmu_notifier_invalidate_range_end, if people agree not to play whack-a-mole with the callers of mmu_notifier_invalidate_range_*.
> 
> - remove the warning in KVM

This probably depends whether it is actually legal to call MMU notifiers
with a zero range, the first time this warning triggered it was the caller
that was fixed [1].

By the way, the warning-on-zero-range was added during memslots patch set
review process [2], but I think it ultimately does make sense.

> Thanks,
> 
> Paolo
> 

Thanks,
Maciej

[1]: https://lore.kernel.org/kvm/20211228234257.1926057-1-seanjc@google.com/
[2]: https://lore.kernel.org/kvm/YKWaFwgMNSaQQuQP@google.com/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [syzbot] WARNING in kvm_mmu_notifier_invalidate_range_start (2)
  2022-03-21 13:42   ` Maciej S. Szmigiero
@ 2022-03-28 15:22     ` Sean Christopherson
  0 siblings, 0 replies; 6+ messages in thread
From: Sean Christopherson @ 2022-03-28 15:22 UTC (permalink / raw)
  To: Maciej S. Szmigiero
  Cc: Paolo Bonzini, syzbot, david, frankja, imbrenda, kvm,
	linux-kernel, syzkaller-bugs, vkuznets, wanpengli, will,
	Linux-MM, Andrew Morton

On Mon, Mar 21, 2022, Maciej S. Szmigiero wrote:
> On 21.03.2022 12:01, Paolo Bonzini wrote:
> > On 3/21/22 11:25, syzbot wrote:
> > diff --git a/mm/mremap.c b/mm/mremap.c
> > index 002eec83e91e..0e175aef536e 100644
> > --- a/mm/mremap.c
> > +++ b/mm/mremap.c
> > @@ -486,6 +486,9 @@ unsigned long move_page_tables(struct vm_area_struct
> >       pmd_t *old_pmd, *new_pmd;
> >       pud_t *old_pud, *new_pud;
> > 
> > +    if (!len)
> > +        return 0;
> > +
> >       old_end = old_addr + len;
> >       flush_cache_range(vma, old_addr, old_end);
> > 
> > but there are several other ways to fix this elsewhere in the call chain:
> > 
> > - check for old_len == 0 somewhere in mremap_to
> > 
> > - skip the call in __mmu_notifier_invalidate_range_start and
> >   __mmu_notifier_invalidate_range_end, if people agree not to play
> >   whack-a-mole with the callers of mmu_notifier_invalidate_range_*.
> > 
> > - remove the warning in KVM
> 
> This probably depends whether it is actually legal to call MMU notifiers
> with a zero range, the first time this warning triggered it was the caller
> that was fixed [1].
> 
> By the way, the warning-on-zero-range was added during memslots patch set
> review process [2], but I think it ultimately does make sense.

My vote is to play whack-a-mole.  This particular flavor isn't all that interesting,
but the HugeTLB bug was a genuine off-by-one error.  Given the low (so far) number
of unique reports, IMO the benefits of detecting buggy callers outweighs the cost of
having to fix/address benign paths where userspace is doing something silly.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-03-28 15:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-21 10:25 [syzbot] WARNING in kvm_mmu_notifier_invalidate_range_start (2) syzbot
2022-03-21 10:25 ` syzbot
2022-03-21 10:25 ` syzbot
2022-03-21 11:01 ` Paolo Bonzini
2022-03-21 13:42   ` Maciej S. Szmigiero
2022-03-28 15:22     ` Sean Christopherson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.