linux-sgx.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: linux-sgx@vger.kernel.org
Subject: Re: [PATCH for_v23 1/9] x86/sgx: WARN once if an enclave is released with unfreed EPC pages
Date: Mon, 14 Oct 2019 23:31:56 +0300	[thread overview]
Message-ID: <20191014203156.GQ15552@linux.intel.com> (raw)
In-Reply-To: <20191010214301.25669-2-sean.j.christopherson@intel.com>

On Thu, Oct 10, 2019 at 02:42:53PM -0700, Sean Christopherson wrote:
> Add a WARN to detect EPC page leaks when releasing an enclave.  The
> release flow uses the common sgx_encl_destroy() helper, which is allowed
> to be called while the reclaimer holds references to the enclave's EPC
> pages and so can't WARN in the scenario where the SECS is leaked because
> it has active child pages.
> 
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
>  arch/x86/kernel/cpu/sgx/encl.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
> index c13c3ba3430a..b4d7b2f9609f 100644
> --- a/arch/x86/kernel/cpu/sgx/encl.c
> +++ b/arch/x86/kernel/cpu/sgx/encl.c
> @@ -511,6 +511,7 @@ void sgx_encl_release(struct kref *ref)
>  		fput(encl->backing);
>  
>  	WARN_ONCE(!list_empty(&encl->mm_list), "mm_list non-empty");
> +	WARN_ON_ONCE(encl->secs_child_cnt || encl->secs.epc_page);

I'd prefer to have two WARN_ON_ONCE()'s. I think disjunction's should
not be used with WARN*() (conjunction's obviously should when they are
required).

I changed this to:

	/* Detect EPC page leak's. */
	WARN_ON_ONCE(encl->secs_child_cnt);
	WARN_ON_ONCE(encl->secs.epc_page);

The patch has been merged.

/Jarkko

  reply	other threads:[~2019-10-14 20:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-10 21:42 [PATCH for_v23 0/9] x86/sgx: misc page related fixes Sean Christopherson
2019-10-10 21:42 ` [PATCH for_v23 1/9] x86/sgx: WARN once if an enclave is released with unfreed EPC pages Sean Christopherson
2019-10-14 20:31   ` Jarkko Sakkinen [this message]
2019-10-14 20:33     ` Jarkko Sakkinen
2019-10-14 23:56       ` Sean Christopherson
2019-10-10 21:42 ` [PATCH for_v23 2/9] x86/sgx: Do not EWB SECS if the enclave is dead Sean Christopherson
2019-10-14 20:58   ` Jarkko Sakkinen
2019-10-10 21:42 ` [PATCH for_v23 3/9] x86/sgx: Fix a memory leak in sgx_encl_destroy() Sean Christopherson
2019-10-10 22:49   ` Sean Christopherson
2019-10-14 21:00     ` Jarkko Sakkinen
2019-10-14 23:57       ` Sean Christopherson
2019-10-10 21:42 ` [PATCH for_v23 4/9] x86/sgx: WARN on any non-zero return from __eremove() Sean Christopherson
2019-10-10 21:42 ` [PATCH for_v23 5/9] x86/sgx: WARN only once if EREMOVE fails Sean Christopherson
2019-10-10 21:42 ` [PATCH for_v23 6/9] x86/sgx: Split second half of sgx_free_page() to a separate helper Sean Christopherson
2019-10-10 21:42 ` [PATCH for_v23 7/9] x86/sgx: Use the post-reclaim variant of __sgx_free_page() Sean Christopherson
2019-10-10 21:43 ` [PATCH for_v23 8/9] x86/sgx: Don't update free page count if EPC section allocation fails Sean Christopherson
2019-10-10 21:43 ` [PATCH for_v23 9/9] x86/sgx: Reinstate per EPC section free page counts Sean Christopherson

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=20191014203156.GQ15552@linux.intel.com \
    --to=jarkko.sakkinen@linux.intel.com \
    --cc=linux-sgx@vger.kernel.org \
    --cc=sean.j.christopherson@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;
as well as URLs for NNTP newsgroup(s).