summaryrefslogtreecommitdiff
path: root/drivers/virt
diff options
context:
space:
mode:
authorLi RongQing <lirongqing@baidu.com>2024-06-19 19:18:01 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-01-02 10:34:22 +0100
commit1429ae7b7d4759a1e362456b8911c701bae655b4 (patch)
tree99d4c3eb83e34445c465b88861b26ca7b5f5f587 /drivers/virt
parentb939f108e86b76119428a6fa4e92491e09ac7867 (diff)
downloadlinux-1429ae7b7d4759a1e362456b8911c701bae655b4.tar.gz
linux-1429ae7b7d4759a1e362456b8911c701bae655b4.tar.bz2
linux-1429ae7b7d4759a1e362456b8911c701bae655b4.zip
virt: tdx-guest: Just leak decrypted memory on unrecoverable errors
commit 27834971f616c5e154423c578fa95e0444444ce1 upstream. 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: f4738f56d1dc ("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 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/virt')
-rw-r--r--drivers/virt/coco/tdx-guest/tdx-guest.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/virt/coco/tdx-guest/tdx-guest.c b/drivers/virt/coco/tdx-guest/tdx-guest.c
index d7db6c824e13..224e7dde9cde 100644
--- a/drivers/virt/coco/tdx-guest/tdx-guest.c
+++ b/drivers/virt/coco/tdx-guest/tdx-guest.c
@@ -124,10 +124,8 @@ static void *alloc_quote_buf(void)
if (!addr)
return NULL;
- if (set_memory_decrypted((unsigned long)addr, count)) {
- free_pages_exact(addr, len);
+ if (set_memory_decrypted((unsigned long)addr, count))
return NULL;
- }
return addr;
}