]> Git Repo - J-linux.git/commitdiff
Drivers: hv: vmbus: Don't free ring buffers that couldn't be re-encrypted
authorMichael Kelley <[email protected]>
Mon, 11 Mar 2024 16:15:58 +0000 (09:15 -0700)
committerWei Liu <[email protected]>
Wed, 10 Apr 2024 21:33:33 +0000 (21:33 +0000)
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: Michael Kelley <[email protected]>
Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
Acked-by: Kirill A. Shutemov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Wei Liu <[email protected]>
Message-ID: <20240311161558[email protected]>

drivers/hv/channel.c

index 98259b4925029217b9f1b3fa6c7399f6a984ff24..fb8cd8469328ee094619c91eb227a04e24bf66cb 100644 (file)
@@ -153,7 +153,9 @@ void vmbus_free_ring(struct vmbus_channel *channel)
        hv_ringbuffer_cleanup(&channel->inbound);
 
        if (channel->ringbuffer_page) {
-               __free_pages(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,
                             get_order(channel->ringbuffer_pagecount
                                       << PAGE_SHIFT));
                channel->ringbuffer_page = NULL;
This page took 0.048996 seconds and 4 git commands to generate.