KVM: SVM: prevent DBG_DECRYPT and DBG_ENCRYPT overflow
authorDavid Rientjes <rientjes@google.com>
Mon, 25 Mar 2019 18:47:31 +0000 (11:47 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 May 2019 05:22:54 +0000 (07:22 +0200)
commit271ea551cfdff55860f8628611d6538dec7dc307
treedb02a4c42694d553a340a0e2635665ac4dcadf0e
parent93e9dabbcdc7b8cd5f6c8e5451963fc1a1771e70
KVM: SVM: prevent DBG_DECRYPT and DBG_ENCRYPT overflow

[ Upstream commit b86bc2858b389255cd44555ce4b1e427b2b770c0 ]

This ensures that the address and length provided to DBG_DECRYPT and
DBG_ENCRYPT do not cause an overflow.

At the same time, pass the actual number of pages pinned in memory to
sev_unpin_memory() as a cleanup.

Reported-by: Cfir Cohen <cfir@google.com>
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
arch/x86/kvm/svm.c