* Re: [syzbot] WARNING in kvm_mmu_notifier_invalidate_range_start (2) [not found] <000000000000b6df0f05dab7e92c@google.com> @ 2022-03-21 11:01 ` Paolo Bonzini 2022-03-21 13:42 ` Maciej S. Szmigiero 0 siblings, 1 reply; 3+ 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] 3+ messages in thread
* Re: [syzbot] WARNING in kvm_mmu_notifier_invalidate_range_start (2) 2022-03-21 11:01 ` [syzbot] WARNING in kvm_mmu_notifier_invalidate_range_start (2) Paolo Bonzini @ 2022-03-21 13:42 ` Maciej S. Szmigiero 2022-03-28 15:22 ` Sean Christopherson 0 siblings, 1 reply; 3+ 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] 3+ 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; 3+ 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] 3+ messages in thread
end of thread, other threads:[~2022-03-28 15:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <000000000000b6df0f05dab7e92c@google.com>
2022-03-21 11:01 ` [syzbot] WARNING in kvm_mmu_notifier_invalidate_range_start (2) Paolo Bonzini
2022-03-21 13:42 ` Maciej S. Szmigiero
2022-03-28 15:22 ` Sean Christopherson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).