]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
KVM: Disallow user memslot with size that exceeds "unsigned long"
authorSean Christopherson <seanjc@google.com>
Thu, 4 Nov 2021 00:25:03 +0000 (00:25 +0000)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 4 Jan 2022 08:49:07 +0000 (09:49 +0100)
commitc72cb57b93ab14628aa5bc0212a16f986142fec1
tree52e06cf596f374a92f08a742289f99178b2e7325
parente70733cee808ee9eb1861e7d86db8aa2d5f7f898
KVM: Disallow user memslot with size that exceeds "unsigned long"

BugLink: https://bugs.launchpad.net/bugs/1953731
commit 6b285a5587506bae084cf9a3ed5aa491d623b91b upstream.

Reject userspace memslots whose size exceeds the storage capacity of an
"unsigned long".  KVM's uAPI takes the size as u64 to support large slots
on 64-bit hosts, but does not account for the size being truncated on
32-bit hosts in various flows.  The access_ok() check on the userspace
virtual address in particular casts the size to "unsigned long" and will
check the wrong number of bytes.

KVM doesn't actually support slots whose size doesn't fit in an "unsigned
long", e.g. KVM's internal kvm_memory_slot.npages is an "unsigned long",
not a "u64", and misc arch specific code follows that behavior.

Fixes: fa3d315a4ce2 ("KVM: Validate userspace_addr of memslot when registered")
Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Message-Id: <20211104002531.1176691-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
virt/kvm/kvm_main.c