]> git.karo-electronics.de Git - karo-tx-linux.git/commit
KVM: x86: check for cr3 validity in ioctl_set_sregs
authorMarcelo Tosatti <mtosatti@redhat.com>
Thu, 16 Apr 2009 11:30:44 +0000 (08:30 -0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 2 Jul 2009 23:49:33 +0000 (16:49 -0700)
commitd42a5ebb5ecc66aa692a1141c7ba284ec612e9cc
tree4dd77dbc3c4d0670550bb93ff6e7a164cbc63773
parent83efa8edb43ad69a5f801334170d41557cdca89b
KVM: x86: check for cr3 validity in ioctl_set_sregs

commit 59839dfff5eabca01cc4e20b45797a60a80af8cb upstream.

Matt T. Yourst notes that kvm_arch_vcpu_ioctl_set_sregs lacks validity
checking for the new cr3 value:

"Userspace callers of KVM_SET_SREGS can pass a bogus value of cr3 to
the kernel. This will trigger a NULL pointer access in gfn_to_rmap()
when userspace next tries to call KVM_RUN on the affected VCPU and kvm
attempts to activate the new non-existent page table root.

This happens since kvm only validates that cr3 points to a valid guest
physical memory page when code *inside* the guest sets cr3. However, kvm
currently trusts the userspace caller (e.g. QEMU) on the host machine to
always supply a valid page table root, rather than properly validating
it along with the rest of the reloaded guest state."

http://sourceforge.net/tracker/?func=detail&atid=893831&aid=2687641&group_id=180599

Check for a valid cr3 address in kvm_arch_vcpu_ioctl_set_sregs, triple
fault in case of failure.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/kvm/x86.c