From: Kai Huang <kai.huang@intel.com>
To: Dave Hansen <dave.hansen@intel.com>,
linux-sgx@vger.kernel.org, x86@kernel.org
Cc: linux-kernel@vger.kernel.org, bp@alien8.de, seanjc@google.com,
jarkko@kernel.org, tglx@linutronix.de, mingo@redhat.com,
Yang Zhong <yang.zhong@intel.com>
Subject: Re: [PATCH] x86/sgx: Add missing xa_destroy() when virtual EPC is destroyed
Date: Wed, 16 Jun 2021 12:28:57 +1200 [thread overview]
Message-ID: <84b136e7368a982c80dc344b17eb992ea73a0896.camel@intel.com> (raw)
In-Reply-To: <89b29a2b-0050-cef4-8bf7-0b3bc2f5c170@intel.com>
On Tue, 2021-06-15 at 08:39 -0700, Dave Hansen wrote:
> On 6/15/21 3:16 AM, Kai Huang wrote:
> > xa_destroy() needs to be called to destroy virtual EPC's page arra
> > before calling kfree() to free the virtual EPC. Currently it is not
> > calaled. Add the missing xa_destroy() to fix.
>
> Looks good Kai, thanks for fixing this.
>
> Could you please take a good look through the sgx_release() and the vpec
> equivalent and see if anything else stands out as possibly being missed?
I looked over. One potential issue is both sgx_encl and sgx_vepc have 'struct mutex lock'
embedded, but mutex_destroy() is not called when they are released. However I am not
sure whether this is worth fixing, since mutex_destroy() is empty unless
CONFIG_DEBUG_MUTEXES is turned on (even with it turned on, mutex_destroy() doesn't do
anything like freeing resources so in practice there should have no problem).
Another thing is sgx_encl_release() doesn't explicitly call xa_erase() for each EPC page
in encl->page_array when looping it over to free all EPC pages, but I think it is OK since
xa_destroy() is called later which will destroy all xarray internal data structures. But
I don't know internal implementation of xarray.
> Also, is this the kind of thing that a simple open/add/close selftest
> might have found?
It might be useful but I don't think it can detect things like xa_destroy() being missing.
>
> Maybe we should beef up the selftests a bit.
>
> Acked-by: Dave Hansen <dave.hansen@intel.com>
Thank you!
prev parent reply other threads:[~2021-06-16 0:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-15 10:16 [PATCH] x86/sgx: Add missing xa_destroy() when virtual EPC is destroyed Kai Huang
2021-06-15 13:20 ` Jarkko Sakkinen
2021-06-16 0:30 ` Kai Huang
2021-06-17 14:34 ` Borislav Petkov
2021-06-18 0:04 ` Kai Huang
2021-06-18 5:15 ` Borislav Petkov
2021-06-15 15:39 ` Dave Hansen
2021-06-16 0:28 ` Kai Huang [this message]
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=84b136e7368a982c80dc344b17eb992ea73a0896.camel@intel.com \
--to=kai.huang@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=jarkko@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yang.zhong@intel.com \
/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