On Wed, Aug 07, 2019 at 05:12:50PM -0700, Sean Christopherson wrote: > Move the EADD/EINIT checks on SGX_ENCL_CREATED to the very beginning of > the ioctl() flows. Deferring the check until the core code is fragile > as all code leading up to that point must be careful that it only uses > members of @encl that are initialized at allocation time. For example, > the flush_work() call in sgx_encl_init() will crash if the enclave has > not been created. > > Note, there is no need to take encl->lock to check SGX_ENCL_CREATED so > long as SGX_ENCL_CREATED is set only after the enclave is fully > initialized, it's not the kernel's responsibility to guard against > sgx_encl_create() racing with EADD/EINIT. Add a comment to highlight > the dependency. > > Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> Acked-by: Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx> /Jarkko