Re: [intel-sgx-kernel-dev] [PATCH v7 4/8] intel_sgx: driver for Intel Software Guard Extensions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2017-12-08 at 07:31 -0800, Christopherson, Sean J wrote:
> Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx> wrote:
> > On Thu, Dec 07, 2017 at 02:46:39PM +0000, Christopherson, Sean J wrote:
> > > > + for (i = 0; i < 2; i++) {
> > > > +         va_page = list_first_entry(&encl->va_pages,
> > > > +                                    struct sgx_va_page, list);
> > > > +         va_offset = sgx_alloc_va_slot(va_page);
> > > > +         if (va_offset < PAGE_SIZE)
> > > > +                 break;
> > > > +
> > > > +         list_move_tail(&va_page->list, &encl->va_pages);
> > > > + }
> > > 
> > > This is broken, there is no guarantee that the next VA page will have
> > > a free slot.  You have to walk over all VA pages to guarantee a slot
> > > is found, e.g. this caused EWB and ELDU errors.
>
> > I did run some extensive stress tests on this and did not experience any
> > issues. Full VA pages are always put to the end. Please point me to the
> > test where this breaks so that I can fix the issue if it persists.
> 
> Three VA pages in the enclave: A, B and C.  Evict all pages in the
> enclave, i.e. consume all slots in A, B and C.  The list can be in
> any order at this point, but for the sake of argument let's say the
> order is C->A->B, i.e. C was originally the last VA page in the list.
> Fault in page X, whose VA is in B.  Evict X.  This code looks at C
> and A, and finds no available slot, but continues with VA page A and
> a va_offset of PAGE_SIZE.

So it looks like you avoid the described case by moving B to the head of
the list in sgx_eldu.  The bug I am seeing is still straightforward to
theorize:

    1. Three VA pages.  List = A->B->C
    2. Fill A and B, use one entry in C.  List = C->B->A
    3. ELDU, freeing a slot in B.  List = B->C->A
    4. EWB, consuming the last slot in B.  List = B->C->A
    5. ELDU, freeing a slot in A.  List = A->B->C
    6. EWB, consuming the last slot in A.  List = A->B->C
    7. ELDU, but both A and B are full
    8. Explode



[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux