]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0)
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 8 Apr 2022 20:09:04 +0000 (13:09 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 12:41:14 +0000 (14:41 +0200)
commit65d5127de89883f8eb6c26961a8b4191e6c5442d
tree21331459dc243a2447d54d3a24b3088d946c1cdb
parent074db37b8a372c94d5755fb2f0bc157d2c8870fe
mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0)

BugLink: https://bugs.launchpad.net/bugs/1969107
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>
(cherry picked from commit a04cb99c5d4668fe3f5c0e5b6da1cecd34c3f219)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
mm/mremap.c