kvm: Disallow wraparound in kvm_gfn_to_hva_cache_init
authorJim Mattson <jmattson@google.com>
Mon, 17 Dec 2018 21:53:33 +0000 (13:53 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 21 Dec 2018 10:28:22 +0000 (11:28 +0100)
commitf1b9dd5eb86cec1fcf66aad17e7701d98d024a9a
treea3905b1d27e8e4514953b4f0aa1eec705fa30afd
parentba7424b200d347fbbf9fadecaffb2a0feb740039
kvm: Disallow wraparound in kvm_gfn_to_hva_cache_init

Previously, in the case where (gpa + len) wrapped around, the entire
region was not validated, as the comment claimed. It doesn't actually
seem that wraparound should be allowed here at all.

Furthermore, since some callers don't check the return code from this
function, it seems prudent to clear ghc->memslot in the event of an
error.

Fixes: 8f964525a121f ("KVM: Allow cross page reads and writes from cached translations.")
Reported-by: Cfir Cohen <cfir@google.com>
Signed-off-by: Jim Mattson <jmattson@google.com>
Reviewed-by: Cfir Cohen <cfir@google.com>
Reviewed-by: Marc Orr <marcorr@google.com>
Cc: Andrew Honig <ahonig@google.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
virt/kvm/kvm_main.c