Commit 30d18df6 authored by Michael Kelley's avatar Michael Kelley Committed by Wei Liu

Drivers: hv: vmbus: Don't free ring buffers that couldn't be re-encrypted

In CoCo VMs it is possible for the untrusted host to cause
set_memory_encrypted() or set_memory_decrypted() to fail such that an
error is returned and the resulting memory is shared. Callers need to
take care to handle these errors to avoid returning decrypted (shared)
memory to the page allocator, which could lead to functional or security
issues.

The VMBus ring buffer code could free decrypted/shared pages if
set_memory_decrypted() fails. Check the decrypted field in the struct
vmbus_gpadl for the ring buffers to decide whether to free the memory.
Signed-off-by: default avatarMichael Kelley <mhklinux@outlook.com>
Reviewed-by: default avatarKuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Link: https://lore.kernel.org/r/20240311161558.1310-6-mhklinux@outlook.comSigned-off-by: default avatarWei Liu <wei.liu@kernel.org>
Message-ID: <20240311161558.1310-6-mhklinux@outlook.com>
parent 3d788b2f
...@@ -153,6 +153,8 @@ void vmbus_free_ring(struct vmbus_channel *channel) ...@@ -153,6 +153,8 @@ void vmbus_free_ring(struct vmbus_channel *channel)
hv_ringbuffer_cleanup(&channel->inbound); hv_ringbuffer_cleanup(&channel->inbound);
if (channel->ringbuffer_page) { if (channel->ringbuffer_page) {
/* In a CoCo VM leak the memory if it didn't get re-encrypted */
if (!channel->ringbuffer_gpadlhandle.decrypted)
__free_pages(channel->ringbuffer_page, __free_pages(channel->ringbuffer_page,
get_order(channel->ringbuffer_pagecount get_order(channel->ringbuffer_pagecount
<< PAGE_SHIFT)); << PAGE_SHIFT));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment