From: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
To: "wei.liu@kernel.org" <wei.liu@kernel.org>
Cc: "linux-coco@lists.linux.dev" <linux-coco@lists.linux.dev>,
"mhklinux@outlook.com" <mhklinux@outlook.com>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"haiyangz@microsoft.com" <haiyangz@microsoft.com>,
"Reshetova, Elena" <elena.reshetova@intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"edumazet@google.com" <edumazet@google.com>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"kirill.shutemov@linux.intel.com"
<kirill.shutemov@linux.intel.com>,
"kys@microsoft.com" <kys@microsoft.com>,
"Cui, Dexuan" <decui@microsoft.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"sathyanarayanan.kuppuswamy@linux.intel.com"
<sathyanarayanan.kuppuswamy@linux.intel.com>
Subject: Re: [RFC RFT PATCH 1/4] hv: Leak pages if set_memory_encrypted() fails
Date: Fri, 1 Mar 2024 19:12:45 +0000 [thread overview]
Message-ID: <dc67979f1e77ee7499483ae03c37af3f0ef119eb.camel@intel.com> (raw)
In-Reply-To: <ZeGfTtlx0JOj9gVS@liuwe-devbox-debian-v2>
On Fri, 2024-03-01 at 09:26 +0000, Wei Liu wrote:
> > Hyperv could free decrypted/shared pages if set_memory_encrypted()
> > fails.
>
> "Hyper-V" throughout.
Ok.
>
> > Leak the pages if this happens.
> >
> > Only compile tested.
> >
> > Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> > Cc: Haiyang Zhang <haiyangz@microsoft.com>
> > Cc: Wei Liu <wei.liu@kernel.org>
> > Cc: Dexuan Cui <decui@microsoft.com>
> > Cc: linux-hyperv@vger.kernel.org
> > Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
> > ---
> > drivers/hv/connection.c | 11 +++++++----
> > 1 file changed, 7 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
> > index 3cabeeabb1ca..e39493421bbb 100644
> > --- a/drivers/hv/connection.c
> > +++ b/drivers/hv/connection.c
> > @@ -315,6 +315,7 @@ int vmbus_connect(void)
> >
> > void vmbus_disconnect(void)
> > {
> > + int ret;
> > /*
> > * First send the unload request to the host.
> > */
> > @@ -337,11 +338,13 @@ void vmbus_disconnect(void)
> > vmbus_connection.int_page = NULL;
> > }
> >
> > - set_memory_encrypted((unsigned
> > long)vmbus_connection.monitor_pages[0], 1);
> > - set_memory_encrypted((unsigned
> > long)vmbus_connection.monitor_pages[1], 1);
> > + ret = set_memory_encrypted((unsigned
> > long)vmbus_connection.monitor_pages[0], 1);
> > + ret |= set_memory_encrypted((unsigned
> > long)vmbus_connection.monitor_pages[1], 1);
> >
> > - hv_free_hyperv_page(vmbus_connection.monitor_pages[0]);
> > - hv_free_hyperv_page(vmbus_connection.monitor_pages[1]);
> > + if (!ret) {
> > + hv_free_hyperv_page(vmbus_connection.monitor_pages[
> > 0]);
> > + hv_free_hyperv_page(vmbus_connection.monitor_pages[
> > 1]);
> > + }
>
> This silently leaks the pages if set_memory_encrypted() fails. I
> think
> there should print some warning or error messages here.
Another patch will warn in CPA for the particular case:
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=x86/mm
Do we want a warning in the caller too? It is more robust to other
types of failures in the future I guess.
next prev parent reply other threads:[~2024-03-01 19:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-22 2:10 [RFC RFT PATCH 0/4] Handle set_memory_XXcrypted() errors in hyperv Rick Edgecombe
2024-02-22 2:10 ` [RFC RFT PATCH 1/4] hv: Leak pages if set_memory_encrypted() fails Rick Edgecombe
2024-03-01 9:26 ` Wei Liu
2024-03-01 19:12 ` Edgecombe, Rick P [this message]
2024-03-01 19:00 ` Michael Kelley
2024-03-01 19:13 ` Edgecombe, Rick P
2024-03-01 20:21 ` Michael Kelley
2024-03-01 20:47 ` Edgecombe, Rick P
2024-02-22 2:10 ` [RFC RFT PATCH 2/4] hv: Track decrypted status in vmbus_gpadl Rick Edgecombe
2024-03-01 19:00 ` Michael Kelley
2024-02-22 2:10 ` [RFC RFT PATCH 3/4] hv_nstvsc: Don't free decrypted memory Rick Edgecombe
2024-03-01 19:01 ` Michael Kelley
2024-02-22 2:10 ` [RFC RFT PATCH 4/4] uio_hv_generic: " Rick Edgecombe
2024-03-01 19:01 ` Michael Kelley
2024-03-01 19:00 ` [RFC RFT PATCH 0/4] Handle set_memory_XXcrypted() errors in hyperv Michael Kelley
2024-03-07 17:11 ` Michael Kelley
2024-03-07 19:12 ` Edgecombe, Rick P
2024-03-07 20:25 ` Michael Kelley
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=dc67979f1e77ee7499483ae03c37af3f0ef119eb.camel@intel.com \
--to=rick.p.edgecombe@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=edumazet@google.com \
--cc=elena.reshetova@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=haiyangz@microsoft.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=kuba@kernel.org \
--cc=kys@microsoft.com \
--cc=linux-coco@lists.linux.dev \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhklinux@outlook.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=wei.liu@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;
as well as URLs for NNTP newsgroup(s).