]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: check userspace_addr for all memslots
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 1 Jun 2020 08:17:45 +0000 (04:17 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 1 Jun 2020 08:18:45 +0000 (04:18 -0400)
commitc7ab562e439e40deea3da4070405271a8639c6d7
tree5b6a0b937eb9b542caf672ed458ba37276c0651e
parent6020dd442a8dd8bef2332750a0b84ca7043937e9
KVM: check userspace_addr for all memslots

The userspace_addr alignment and range checks are not performed for private
memory slots that are prepared by KVM itself.  This is unnecessary and makes
it questionable to use __*_user functions to access memory later on.  We also
rely on the userspace address being aligned since we have an entire family
of functions to map gfn to pfn.

Fortunately skipping the check is completely unnecessary.  Only x86 uses
private memslots and their userspace_addr is obtained from vm_mmap,
therefore it must be below PAGE_OFFSET.  In fact, any attempt to pass
an address above PAGE_OFFSET would have failed because such an address
would return true for kvm_is_error_hva.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
virt/kvm/kvm_main.c