diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2022-04-08 23:09:04 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-04-13 22:01:08 +0300 |
commit | 7d659cb1763ff17d1c6ee082fa6feb4267c7a30b (patch) | |
tree | 3951cd18d03f7bfcc966a8dea04a39f5eb68a3ce /mm/mremap.c | |
parent | 6adc01a7aa37445dafe8846faa0610a86029b253 (diff) | |
download | linux-7d659cb1763ff17d1c6ee082fa6feb4267c7a30b.tar.xz |
mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0)
commit 01e67e04c28170c47700c2c226d732bbfedb1ad0 upstream.
If an mremap() syscall with old_size=0 ends up in move_page_tables(), it
will call invalidate_range_start()/invalidate_range_end() unnecessarily,
i.e. with an empty range.
This causes a WARN in KVM's mmu_notifier. In the past, empty ranges
have been diagnosed to be off-by-one bugs, hence the WARNing. Given the
low (so far) number of unique reports, the benefits of detecting more
buggy callers seem to outweigh the cost of having to fix cases such as
this one, where userspace is doing something silly. In this particular
case, an early return from move_page_tables() is enough to fix the
issue.
Link: https://lkml.kernel.org/r/20220329173155.172439-1-pbonzini@redhat.com
Reported-by: syzbot+6bde52d89cfdf9f61425@syzkaller.appspotmail.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm/mremap.c')
-rw-r--r-- | mm/mremap.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/mm/mremap.c b/mm/mremap.c index 138abbae4f75..d4c8d6cca3f4 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -260,6 +260,9 @@ unsigned long move_page_tables(struct vm_area_struct *vma, struct mmu_notifier_range range; pmd_t *old_pmd, *new_pmd; + if (!len) + return 0; + old_end = old_addr + len; flush_cache_range(vma, old_addr, old_end); |