diff options
author | Dan Carpenter <dan.carpenter@linaro.org> | 2024-06-12 14:50:39 +0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2024-08-13 06:08:40 -0400 |
commit | cd2d00606553e631e9b5d11cca7da38fc95433e6 (patch) | |
tree | 06975ba1614050cbf21f0b168f1b934405de47b6 | |
parent | 696eb24ac2af632ddcb422114b2d8498af1de20c (diff) | |
download | linux-stable-cd2d00606553e631e9b5d11cca7da38fc95433e6.tar.gz linux-stable-cd2d00606553e631e9b5d11cca7da38fc95433e6.tar.bz2 linux-stable-cd2d00606553e631e9b5d11cca7da38fc95433e6.zip |
KVM: SVM: Fix an error code in sev_gmem_post_populate()
The copy_from_user() function returns the number of bytes which it
was not able to copy. Return -EFAULT instead.
Fixes: dee5a47cc7a4 ("KVM: SEV: Add KVM_SEV_SNP_LAUNCH_UPDATE command")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Message-ID: <20240612115040.2423290-4-dan.carpenter@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | arch/x86/kvm/svm/sev.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 393f450adbc3..714c517dd4b7 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -2290,9 +2290,10 @@ static int sev_gmem_post_populate(struct kvm *kvm, gfn_t gfn_start, kvm_pfn_t pf if (src) { void *vaddr = kmap_local_pfn(pfn + i); - ret = copy_from_user(vaddr, src + i * PAGE_SIZE, PAGE_SIZE); - if (ret) + if (copy_from_user(vaddr, src + i * PAGE_SIZE, PAGE_SIZE)) { + ret = -EFAULT; goto err; + } kunmap_local(vaddr); } |