public inbox for linux-sgx@vger.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Dave Hansen <dave.hansen@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, Andy Lutomirski <luto@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	linux-sgx@vger.kernel.org, Harald Hoyer <harald@profian.com>,
	Nathaniel McCallum <nathaniel@profian.com>
Subject: Re: [PATCH] x86/sgx: Allow enclaves to use Asynchrounous Exit Notification
Date: Mon, 11 Jul 2022 13:46:31 +0300	[thread overview]
Message-ID: <Ysv/h31LvLUaXKj5@kernel.org> (raw)
In-Reply-To: <YsuMK0JIYqqjtVdk@kernel.org>

On Mon, Jul 11, 2022 at 05:34:48AM +0300, Jarkko Sakkinen wrote:
> On Tue, Jul 05, 2022 at 11:36:48AM -0700, Dave Hansen wrote:
> > Short Version:
> > 
> > Allow enclaves to use the new Asynchronous EXit (AEX)
> > notification mechanism.  This mechanism lets enclaves run a
> > handler after an AEX event.  These handlers can run mitigations
> > for things like SGX-Step[1].
> > 
> > AEX Notify will be made available both on upcoming processors and
> > on some older processors through microcode updates.
> > 
> > Long Version:
> > 
> > == SGX Attribute Background ==
> > 
> > The SGX architecture includes a list of SGX "attributes".  These
> > attributes ensure consistency and transparency around specific
> > enclave features.
> > 
> > As a simple example, the "DEBUG" attribute allows an enclave to
> > be debugged, but also destroys virtually all of SGX security.
> > Using attributes, enclaves can know that they are being debugged.
> > Attributes also affect enclave attestation so an enclave can, for
> > instance, be denied access to secrets while it is being debugged.
> > 
> > The kernel keeps a list of known attributes and will only
> > initialize enclaves that use a known set of attributes.  This
> > kernel policy eliminates the chance that a new SGX attribute
> > could cause undesired effects.
> > 
> > For example, imagine a new attribute was added called
> > "PROVISIONKEY2" that provided similar functionality to
> > "PROVISIIONKEY".  A kernel policy that allowed indiscriminate use
> > of unknown attributes and thus PROVISIONKEY2 would undermine the
> > existing kernel policy which limits use of PROVISIONKEY enclaves.
> > 
> > == AEX Notify Background ==
> > 
> > "Intel Architecture Instruction Set Extensions and Future
> > Features - Version 45" is out[2].  There is a new chapter:
> > 
> > 	Asynchronous Enclave Exit Notify and the EDECCSSA User Leaf Function.
> > 
> > Enclaves exit can be either synchronous and consensual (EEXIT for
> > instance) or asynchronous (on an interrupt or fault).  The
> > asynchronous ones can evidently be exploited to single step
> > enclaves[1], on top of which other naughty things can be built.
> > 
> > AEX Notify will be made available both on upcoming processors and
> > on some older processors through microcode updates.
> > 
> > == The Problem ==
> > 
> > These attacks are currently entirely opaque to the enclave since
> > the hardware does the save/restore under the covers. The
> > Asynchronous Enclave Exit Notify (AEX Notify) mechanism provides
> > enclaves an ability to detect and mitigate potential exposure to
> > these kinds of attacks.
> > 
> > == The Solution ==
> > 
> > Define the new attribute value for AEX Notification.  Ensure the
> > attribute is cleared from the list reserved attributes which
> > allows it to be used in enclaves.
> > 
> > I just built this and ran it to make sure there were no obvious
> > regressions since I do not have the hardware to test it handy.
> > Tested-by's would be much appreciated.
> 
> Is this available on recent ucode updates e.g. for Icelake
> or Geminilake?

I mean it would not take me long to upgrade our exception handling flow
to this. Then I can run our full test suite on it. But this will of
course require ucode update for Icelake.

AEX Notify will actually just simplify everything. We kind of simulate
"AEX Notify" already with EENTER to execute in-enclave exception handler
before doing actual ERESUME.

BR, Jarkko

  reply	other threads:[~2022-07-11 11:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-05 18:36 [PATCH] x86/sgx: Allow enclaves to use Asynchrounous Exit Notification Dave Hansen
2022-07-11  2:34 ` Jarkko Sakkinen
2022-07-11 10:46   ` Jarkko Sakkinen [this message]
2022-07-19 16:24   ` Dave Hansen
2022-07-14 13:19 ` Haitao Huang
2022-07-19 17:53   ` Dave Hansen
2022-07-19 17:54   ` Dave Hansen
2022-07-20  1:38     ` Haitao Huang
2022-07-28  7:52     ` Jarkko Sakkinen

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=Ysv/h31LvLUaXKj5@kernel.org \
    --to=jarkko@kernel.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=harald@profian.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=nathaniel@profian.com \
    --cc=tglx@linutronix.de \
    --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