Re: [syzbot] WARNING in kvm_mmu_notifier_invalidate_range_start (2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
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





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux