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 v2 2/5] x86/sgx: Reject concurrent ioctls on single enclave
Date: Thu, 29 Aug 2019 21:14:38 +0300	[thread overview]
Message-ID: <20190829181438.oxix5d7qfgru7bd7@linux.intel.com> (raw)
In-Reply-To: <20190829160001.GD26580@linux.intel.com>

On Thu, Aug 29, 2019 at 09:00:01AM -0700, Sean Christopherson wrote:
> > #PF handler should be good as it has this conditional:
> > 
> > flags = atomic_read(&encl->flags);
> > 
> > if ((flags & SGX_ENCL_DEAD) || !(flags & SGX_ENCL_INITIALIZED))
> > 	return ERR_PTR(-EFAULT);
> > 
> > What about the reclaimer?
> 
> Can you elaborate?  I'm not sure what you're asking.

I'm thinking of a race between list_add() in the ioctl and
list_move_tail() in the reclaimer.

A quick way to fix this would be move sgx_alloc_va_page() from
sgx_encl_grow() and return NULL if a new allocation is required.

In the ioctl you can then allocate the page before taking locks and
do "list_add(&va_page->list, &encl->va_pages);" behind the locks.

/Jarkko

  reply	other threads:[~2019-08-29 18:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27 19:27 [PATCH v2 0/5] x86/sgx: Fix lock ordering bug w/ EADD Sean Christopherson
2019-08-27 19:27 ` [PATCH v2 1/5] x86/sgx: Convert encl->flags from an unsigned int to an atomic Sean Christopherson
2019-08-29 13:09   ` Jarkko Sakkinen
2019-08-29 15:59     ` Sean Christopherson
2019-08-29 18:01       ` Jarkko Sakkinen
2019-08-30  0:02     ` Sean Christopherson
2019-08-27 19:27 ` [PATCH v2 2/5] x86/sgx: Reject concurrent ioctls on single enclave Sean Christopherson
2019-08-29 13:15   ` Jarkko Sakkinen
2019-08-29 16:00     ` Sean Christopherson
2019-08-29 18:14       ` Jarkko Sakkinen [this message]
2019-08-29 18:43         ` Sean Christopherson
2019-08-29 22:22           ` Jarkko Sakkinen
2019-08-27 19:27 ` [PATCH v2 3/5] x86/sgx: Take encl->lock inside of mm->mmap_sem for EADD Sean Christopherson
2019-08-27 19:27 ` [PATCH v2 4/5] x86/sgx: Reject all ioctls on dead enclaves Sean Christopherson
2019-08-27 19:27 ` [PATCH v2 5/5] x86/sgx: Destroy the enclave if EEXTEND fails 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=20190829181438.oxix5d7qfgru7bd7@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).