From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: Haitao Huang <haitao.huang@linux.intel.com>
Cc: Sean Christopherson <sean.j.christopherson@intel.com>,
x86@kernel.org, linux-sgx@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org,
Jethro Beekman <jethro@fortanix.com>,
Chunyang Hui <sanqian.hcy@antfin.com>,
Jordan Hand <jorhand@linux.microsoft.com>,
Nathaniel McCallum <npmccallum@redhat.com>,
Seth Moore <sethmo@google.com>,
Suresh Siddha <suresh.b.siddha@intel.com>,
akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com,
asapek@google.com, bp@alien8.de, cedric.xing@intel.com,
chenalexchen@google.com, conradparker@google.com,
cyhanish@google.com, dave.hansen@intel.com,
josh@joshtriplett.org, kai.huang@intel.com, kai.svahn@intel.com,
kmoy@google.com, ludloff@google.com, luto@kernel.org,
nhorman@redhat.com, puiterwijk@redhat.com, rientjes@google.com,
tglx@linutronix.de, yaozhangx@google.com
Subject: Re: [PATCH v33 11/21] x86/sgx: Linux Enclave Driver
Date: Fri, 4 Sep 2020 15:01:26 +0300 [thread overview]
Message-ID: <20200904120126.GB39023@linux.intel.com> (raw)
In-Reply-To: <op.0qaqw6rvwjvjmi@hhuan26-mobl1.amr.corp.intel.com>
On Tue, Sep 01, 2020 at 10:06:32PM -0500, Haitao Huang wrote:
> On Fri, 03 Jul 2020 22:31:10 -0500, Jarkko Sakkinen
> <jarkko.sakkinen@linux.intel.com> wrote:
>
> > On Wed, Jul 01, 2020 at 08:59:02PM -0700, Sean Christopherson wrote:
> > > On Thu, Jun 18, 2020 at 01:08:33AM +0300, Jarkko Sakkinen wrote:
> > > > +static int sgx_validate_secs(const struct sgx_secs *secs,
> > > > + unsigned long ssaframesize)
> > > > +{
> > > > + if (secs->size < (2 * PAGE_SIZE) || !is_power_of_2(secs->size))
> > > > + return -EINVAL;
> > > > +
> > > > + if (secs->base & (secs->size - 1))
> > > > + return -EINVAL;
> > > > +
> > > > + if (secs->miscselect & sgx_misc_reserved_mask ||
> > > > + secs->attributes & sgx_attributes_reserved_mask ||
> > > > + secs->xfrm & sgx_xfrm_reserved_mask)
> > > > + return -EINVAL;
> > > > +
> > > > + if (secs->attributes & SGX_ATTR_MODE64BIT) {
> > > > + if (secs->size > sgx_encl_size_max_64)
> > > > + return -EINVAL;
> > > > + } else if (secs->size > sgx_encl_size_max_32)
> > > > + return -EINVAL;
> > >
> > > These should be >=, not >, the SDM uses one of those fancy ≥ ligatures.
> > >
> > > Internal versions use more obvious pseudocode, e.g.:
> > >
> > > if ((DS:TMP_SECS.ATTRIBUTES.MODE64BIT = 1) AND
> > > (DS:TMP_SECS.SIZE AND (~((1 << CPUID.18.0:EDX[15:8]) – 1)))
> > > {
> > > #GP(0);
> >
> > Updated as:
> >
> > static int sgx_validate_secs(const struct sgx_secs *secs)
> > {
> > u64 max_size = (secs->attributes & SGX_ATTR_MODE64BIT) ?
> > sgx_encl_size_max_64 : sgx_encl_size_max_32;
> >
> > if (secs->size < (2 * PAGE_SIZE) || !is_power_of_2(secs->size))
> > return -EINVAL;
> >
> > if (secs->base & (secs->size - 1))
> > return -EINVAL;
> >
> > if (secs->miscselect & sgx_misc_reserved_mask ||
> > secs->attributes & sgx_attributes_reserved_mask ||
> > secs->xfrm & sgx_xfrm_reserved_mask)
> > return -EINVAL;
> >
> > if (secs->size >= max_size)
> > return -EINVAL;
> >
>
> This should be > not >=. Issue raised and fixed by Fábio Silva for ported
> patches for OOT SGX support:
> https://github.com/intel/SGXDataCenterAttestationPrimitives/pull/123
>
> I tested and verified with Intel arch, the comparison indeed should be >.
>
> Thanks
> Haitao
Thans a lot!
I added this changelog entry to the v37 log:
* Fixed off-by-one error in a size calculation:
https://github.com/intel/SGXDataCenterAttestationPrimitives/commit/e44cc238becf584cc079aef40b557c6af9a03f38
Given the Boris' earlier feedback I xref every changelog
entry in v37 changelog. Then it is also less time consuming
to spot if something is missing.
/Jarkko
next prev parent reply other threads:[~2020-09-04 12:02 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200617220844.57423-1-jarkko.sakkinen@linux.intel.com>
2020-06-17 22:08 ` [PATCH v33 11/21] x86/sgx: Linux Enclave Driver Jarkko Sakkinen
2020-06-25 17:23 ` Borislav Petkov
2020-06-25 18:34 ` Sean Christopherson
2020-06-25 18:45 ` Borislav Petkov
2020-06-26 14:19 ` Jarkko Sakkinen
2020-06-25 20:21 ` Jarkko Sakkinen
2020-06-25 20:25 ` Borislav Petkov
2020-06-26 13:40 ` Jarkko Sakkinen
2020-06-25 18:53 ` Borislav Petkov
2020-06-26 14:17 ` Jarkko Sakkinen
2020-06-26 9:14 ` Borislav Petkov
2020-06-26 14:16 ` Sean Christopherson
2020-06-26 14:20 ` Borislav Petkov
2020-07-03 23:04 ` Jarkko Sakkinen
2020-07-03 3:09 ` Jarkko Sakkinen
2020-06-26 15:34 ` Borislav Petkov
2020-07-04 0:13 ` Jarkko Sakkinen
2020-10-26 21:26 ` Dave Hansen
2020-10-27 1:52 ` Jarkko Sakkinen
2020-10-27 10:05 ` Borislav Petkov
2020-10-27 15:20 ` Dave Hansen
2020-10-27 15:37 ` Borislav Petkov
2020-06-27 17:43 ` Borislav Petkov
2020-06-29 15:27 ` Sean Christopherson
2020-06-29 15:37 ` Borislav Petkov
2020-07-04 1:43 ` Jarkko Sakkinen
2020-07-07 1:38 ` Sean Christopherson
2020-07-07 3:29 ` Jarkko Sakkinen
2020-07-04 1:42 ` Jarkko Sakkinen
2020-07-02 3:59 ` Sean Christopherson
2020-07-04 3:31 ` Jarkko Sakkinen
2020-09-02 3:06 ` Haitao Huang
2020-09-02 16:10 ` Sean Christopherson
2020-09-02 18:40 ` Haitao Huang
2020-09-04 12:01 ` Jarkko Sakkinen [this message]
2020-06-17 22:08 ` [PATCH v33 12/21] x86/sgx: Allow a limited use of ATTRIBUTE.PROVISIONKEY for attestation Jarkko Sakkinen
2020-06-29 16:02 ` Borislav Petkov
2020-06-29 22:04 ` Sean Christopherson
2020-06-30 8:49 ` Borislav Petkov
2020-06-30 14:20 ` Sean Christopherson
2020-06-30 17:13 ` Andy Lutomirski
2020-07-02 20:47 ` Dr. Greg
2020-07-03 2:43 ` Jarkko Sakkinen
2020-07-03 2:38 ` Jarkko Sakkinen
2020-07-03 2:32 ` Jarkko Sakkinen
2020-07-03 2:55 ` 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=20200904120126.GB39023@linux.intel.com \
--to=jarkko.sakkinen@linux.intel.com \
--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@linux.intel.com \
--cc=jethro@fortanix.com \
--cc=jorhand@linux.microsoft.com \
--cc=josh@joshtriplett.org \
--cc=kai.huang@intel.com \
--cc=kai.svahn@intel.com \
--cc=kmoy@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=ludloff@google.com \
--cc=luto@kernel.org \
--cc=nhorman@redhat.com \
--cc=npmccallum@redhat.com \
--cc=puiterwijk@redhat.com \
--cc=rientjes@google.com \
--cc=sanqian.hcy@antfin.com \
--cc=sean.j.christopherson@intel.com \
--cc=sethmo@google.com \
--cc=suresh.b.siddha@intel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).