]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: SVM: Use kzalloc for sev ioctl interfaces to prevent kernel data leak
authorAshish Kalra <ashish.kalra@amd.com>
Mon, 16 May 2022 15:43:10 +0000 (15:43 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 25 May 2022 09:11:51 +0000 (05:11 -0400)
commite9d4ae63997f9022e2e3f2365d7c937f4864aac3
tree352ba2dc6bc40b0bde39a5bee2f7d9cad988d5ee
parentaa3286327f3d41772dc9195f535bdf6dc19f14d5
KVM: SVM: Use kzalloc for sev ioctl interfaces to prevent kernel data leak

For some sev ioctl interfaces, the length parameter that is passed maybe
less than or equal to SEV_FW_BLOB_MAX_SIZE, but larger than the data
that PSP firmware returns. In this case, kmalloc will allocate memory
that is the size of the input rather than the size of the data.
Since PSP firmware doesn't fully overwrite the allocated buffer, these
sev ioctl interface may return uninitialized kernel slab memory.

Reported-by: Andy Nguyen <theflow@google.com>
Suggested-by: David Rientjes <rientjes@google.com>
Suggested-by: Peter Gonda <pgonda@google.com>
Cc: kvm@vger.kernel.org
Cc: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Fixes: 4459b52063207 ("KVM: SVM: Move SEV code to separate file")
Fixes: 9442fbf2a2267 ("KVM: SVM: add support for SEV attestation command")
Fixes: 86e435d780581 ("KVM: SVM: Add KVM_SEV SEND_START command")
Fixes: 1d520dec34f3d ("KVM: SVM: Add KVM_SEND_UPDATE_DATA command")
Fixes: 84df5436d22d9 ("KVM: x86: Account a variety of miscellaneous allocations")
Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
Reviewed-by: Peter Gonda <pgonda@google.com>
Message-Id: <20220516154310.3685678-1-Ashish.Kalra@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/sev.c