Skip to content

Commit bbf9ac3

Browse files
rpedgecoliuw
authored andcommitted
hv_netvsc: Don't free decrypted memory
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 netvsc driver could free decrypted/shared pages if set_memory_decrypted() fails. Check the decrypted field in the gpadl to decide whether to free the memory. Signed-off-by: Rick Edgecombe <[email protected]> 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: <[email protected]>
1 parent 211f514 commit bbf9ac3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/net/hyperv/netvsc.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,11 @@ static void free_netvsc_device(struct rcu_head *head)
154154
int i;
155155

156156
kfree(nvdev->extension);
157-
vfree(nvdev->recv_buf);
158-
vfree(nvdev->send_buf);
157+
158+
if (!nvdev->recv_buf_gpadl_handle.decrypted)
159+
vfree(nvdev->recv_buf);
160+
if (!nvdev->send_buf_gpadl_handle.decrypted)
161+
vfree(nvdev->send_buf);
159162
bitmap_free(nvdev->send_section_map);
160163

161164
for (i = 0; i < VRSS_CHANNEL_MAX; i++) {

0 commit comments

Comments
 (0)