public inbox for linux-coco@lists.linux.dev
 help / color / mirror / Atom feed
From: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
To: "kirill.shutemov@linux.intel.com"
	<kirill.shutemov@linux.intel.com>,
	"linux-coco@lists.linux.dev" <linux-coco@lists.linux.dev>,
	"lirongqing@baidu.com" <lirongqing@baidu.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH][v2] virt: tdx-guest: Don't free decrypted memory
Date: Fri, 14 Jun 2024 16:13:46 +0000	[thread overview]
Message-ID: <c209517e42fa83cbc3f030293f89813a6c1cfce1.camel@intel.com> (raw)
In-Reply-To: <20240614051452.14548-1-lirongqing@baidu.com>

On Fri, 2024-06-14 at 13:14 +0800, Li RongQing wrote:
> 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.
> 
> So when set_memory_decrypted fails, leak decrypted memory, and
> print an error message
> 
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
> diff with v1: leak the page, and print error
> 
>  drivers/virt/coco/tdx-guest/tdx-guest.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/virt/coco/tdx-guest/tdx-guest.c b/drivers/virt/coco/tdx-
> guest/tdx-guest.c
> index 1253bf7..3a6e76c8 100644
> --- a/drivers/virt/coco/tdx-guest/tdx-guest.c
> +++ b/drivers/virt/coco/tdx-guest/tdx-guest.c
> @@ -125,7 +125,7 @@ static void *alloc_quote_buf(void)
>                 return NULL;
>  
>         if (set_memory_decrypted((unsigned long)addr, count)) {
> -               free_pages_exact(addr, len);
> +               pr_err("Failed to set Quote buffer decrypted, leak the
> buffer\n");
>                 return NULL;
>         }

I'm not sure we need the error message, because the set_memory() failure we are
most worried about already has a WARN. But, I could be convinced either way. It
seems to fit with the other code in the file.

Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com>

  reply	other threads:[~2024-06-14 16:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-14  5:14 [PATCH][v2] virt: tdx-guest: Don't free decrypted memory Li RongQing
2024-06-14 16:13 ` Edgecombe, Rick P [this message]
2024-06-17 10:03   ` kirill.shutemov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c209517e42fa83cbc3f030293f89813a6c1cfce1.camel@intel.com \
    --to=rick.p.edgecombe@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lirongqing@baidu.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox