public inbox for linux-sgx@vger.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Borislav Petkov <bp@alien8.de>
Cc: Jethro Beekman <jethro@fortanix.com>,
	linux-sgx@vger.kernel.org, Shuah Khan <shuah@kernel.org>,
	linux-kselftest@vger.kernel.org, akpm@linux-foundation.org,
	andriy.shevchenko@linux.intel.com, asapek@google.com,
	cedric.xing@intel.com, chenalexchen@google.com,
	conradparker@google.com, cyhanish@google.com,
	dave.hansen@intel.com, haitao.huang@intel.com,
	kai.huang@intel.com, kai.svahn@intel.com, kmoy@google.com,
	ludloff@google.com, luto@kernel.org, nhorman@redhat.com,
	npmccallum@redhat.com, puiterwijk@redhat.com,
	rientjes@google.com, sean.j.christopherson@intel.com,
	tglx@linutronix.de, yaozhangx@google.com, mikko.ylinen@intel.com
Subject: Re: [PATCH] selftests/x86: Fix malformed src_offset initialization
Date: Wed, 18 Nov 2020 17:24:29 +0200	[thread overview]
Message-ID: <20201118152429.GC30164@kernel.org> (raw)
In-Reply-To: <20201118114703.GD7472@zn.tnic>

On Wed, Nov 18, 2020 at 12:47:03PM +0100, Borislav Petkov wrote:
> On Wed, Nov 18, 2020 at 12:44:44PM +0100, Borislav Petkov wrote:
> > 0x0000000000000000 0x0000000000002000 0x03
> > 0x0000000000002000 0x0000000000001000 0x05
> > 0x0000000000003000 0x0000000000003000 0x03
> > encl_load: encl->nr_segments: 3
> > encl_load: seg2 offset: 0x3000, seg2 size: 12288
> > encl_load: encl_size: 32768, src_size: 24576
> > encl_map_area: encl_size: 32768
> > encl_map_area: area: 0x0x7feae0db2000
> > encl_map_area: encl_base: 0x7feae0db8000
> > SGX_IOC_ENCLAVE_INIT failed: errno=1
> 
> Running that same thing again succeeded this time:
> 
> 0x0000000000000000 0x0000000000002000 0x03
> 0x0000000000002000 0x0000000000001000 0x05
> 0x0000000000003000 0x0000000000003000 0x03
> encl_load: encl->nr_segments: 3
> encl_load: seg2 offset: 0x3000, seg2 size: 12288
> encl_load: encl_size: 32768, src_size: 24576
> encl_map_area: encl_size: 32768
> encl_map_area: area: 0x0x7f846bec0000
> encl_map_area: encl_base: 0x7f846bec0000
> mapping segment 0, seg->prot: (read write )
> base: 0x7f846bec0000, offset 0x0, size: 8192
> mapping segment 1, seg->prot: (read  exec)
> base: 0x7f846bec0000, offset 0x2000, size: 4096
> mapping segment 2, seg->prot: (read write )
> base: 0x7f846bec0000, offset 0x3000, size: 12288
> SUCCESS
> 
> then I did a couple of successful runs and the next one failed again:
> 
> 0x0000000000000000 0x0000000000002000 0x03
> 0x0000000000002000 0x0000000000001000 0x05
> 0x0000000000003000 0x0000000000003000 0x03
> encl_load: encl->nr_segments: 3
> encl_load: seg2 offset: 0x3000, seg2 size: 12288
> encl_load: encl_size: 32768, src_size: 24576
> encl_map_area: encl_size: 32768
> encl_map_area: area: 0x0x7fb09d4a0000
> encl_map_area: encl_base: 0x7fb09d4a0000
> SGX_IOC_ENCLAVE_INIT failed: errno=1
> 
> Fun.

If you adjust log level, then you should probably see this from
sgx_enclave_init():

	} else if (ret) {
		pr_debug("EINIT returned %d\n", ret);
		ret = -EPERM;
	}

EINIT fails with big certainty because SIGSTRUCT is malformed. The only
dynamic thing in that process is RSA key generation sigstruct.c.
Otherwise, everything is static between the runs. That's why I'm quite
confident that key generation is the issue. Given how the issue behaves
I'd guess it eats the entropy pool.

So what I would propose is that I fix this by adding a static 3072-bit
key and remove the generation code

I found a patch that I can use to revert dynamic generation:

https://lore.kernel.org/linux-sgx/20200319023306.6875-1-jarkko.sakkinen@linux.intel.com/

> -- 
> Regards/Gruss,
>     Boris.
> 
> https://people.kernel.org/tglx/notes-about-netiquette

/Jarkko

  parent reply	other threads:[~2020-11-18 15:24 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-17 22:36 [PATCH] selftests/x86: Fix malformed src_offset initialization Jarkko Sakkinen
2020-11-18 11:11 ` Borislav Petkov
2020-11-18 11:18   ` Jethro Beekman
2020-11-18 11:44     ` Borislav Petkov
2020-11-18 11:47       ` Borislav Petkov
2020-11-18 11:49         ` Borislav Petkov
2020-11-18 15:24         ` Jarkko Sakkinen [this message]
2020-11-18 15:30           ` Jarkko Sakkinen
2020-11-18 12:00       ` Jethro Beekman
2020-11-18 12:15         ` Borislav Petkov
2020-11-18 15:27           ` Jarkko Sakkinen
2020-11-18 17:09         ` Jarkko Sakkinen
2020-11-18 15:07   ` Jarkko Sakkinen
2020-11-18 17:19 ` Borislav Petkov
2020-11-18 17:58   ` Jarkko Sakkinen
2020-11-18 18:04     ` Borislav Petkov
2020-11-18 21:37       ` Jarkko Sakkinen
2020-11-18 21:54         ` Borislav Petkov
2020-11-19  1:16           ` Andy Lutomirski
2020-11-19 16:44             ` Jarkko Sakkinen
2020-11-19 16:41           ` Jarkko Sakkinen
2020-11-19 18:04             ` Borislav Petkov
2020-11-19  1:05         ` Dr. Greg

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=20201118152429.GC30164@kernel.org \
    --to=jarkko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=asapek@google.com \
    --cc=bp@alien8.de \
    --cc=cedric.xing@intel.com \
    --cc=chenalexchen@google.com \
    --cc=conradparker@google.com \
    --cc=cyhanish@google.com \
    --cc=dave.hansen@intel.com \
    --cc=haitao.huang@intel.com \
    --cc=jethro@fortanix.com \
    --cc=kai.huang@intel.com \
    --cc=kai.svahn@intel.com \
    --cc=kmoy@google.com \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=ludloff@google.com \
    --cc=luto@kernel.org \
    --cc=mikko.ylinen@intel.com \
    --cc=nhorman@redhat.com \
    --cc=npmccallum@redhat.com \
    --cc=puiterwijk@redhat.com \
    --cc=rientjes@google.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=shuah@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=yaozhangx@google.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