Skip to content

Commit 2783497

Browse files
lrq-maxIngo Molnar
authored andcommitted
virt: tdx-guest: Just leak decrypted memory on unrecoverable errors
In CoCo VMs it is possible for the untrusted host to cause 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. Leak the decrypted memory when set_memory_decrypted() fails, and don't need to print an error since set_memory_decrypted() will call WARN_ONCE(). Fixes: f4738f5 ("virt: tdx-guest: Add Quote generation support using TSM_REPORTS") Signed-off-by: Li RongQing <lirongqing@baidu.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/all/20240619111801.25630-1-lirongqing%40baidu.com
1 parent dc81e55 commit 2783497

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/virt/coco/tdx-guest/tdx-guest.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,8 @@ static void *alloc_quote_buf(void)
124124
if (!addr)
125125
return NULL;
126126

127-
if (set_memory_decrypted((unsigned long)addr, count)) {
128-
free_pages_exact(addr, len);
127+
if (set_memory_decrypted((unsigned long)addr, count))
129128
return NULL;
130-
}
131129

132130
return addr;
133131
}

0 commit comments

Comments
 (0)