Re: [RFC PATCH 0/4] SGX shmem backing store issue

Jarkko Sakkinen
2022-05-12T14:09:09Z

On Wed, May 11, 2022 at 10:23:29AM -0700, Reinette Chatre wrote:
> Hi Jarkko,
>
> On 5/10/2022 3:28 PM, Jarkko Sakkinen wrote:
> > Let's just say that I came a bit late to the series, and should have read
> > the whole thread before responding to anything. As long as enclave lock is
> > kept on both sides things should be fine.
>
> For the most part, yes. The remaining scenario is the case when the reclaimer
> releases the enclave mutex while keeping a reference to the backing store pages.
> By releasing the enclave mutex there is opportunity for page fault
> handler to run and also operate on the backing store. Both the reclaimer
> (after patch 3/4 in this series) and page fault handler operate on
> the backing store with enclave mutex held but if that is done without
> taking backing store references into account data could be lost. This is
> addressed in the following series with:
> https://lore.kernel.org/linux-sgx/d0ace4a1770ab8f4196bfeae06d0970ddb14ef01.1652131695.git.reinette.chatre@intel.com/

Right, I get it now. Great job figuring all this out!

> >
> > I think for bugs like these it would make sense to put them out early as
> > possible, e.g. I would be fine getting them from kernel bugzilla. Now there
> > there was two week latency on finding the issue, and making it public.
> > Unless there is something confidential, it would be best to get early
> > alert. I'm always ready to change my priorities to help to fix such issues.
>
> I am sorry about this. The reason I first struggled with this by myself was
> because it was made out to be an SGX2 issue. This was made worse when I was not
> able to create an SGX1 test case that can trigger the issue. I thus lacked
> evidence that it is an upstream issue and it took me a while to debug and
> understand the issue to gain confidence that it is indeed an upstream issue.

No worries, just making the crash log available early on gives a chance
to investigate it :-) We can then figure out whether it is SGX2 issue or
not, or any other circumstance. There should be a low-barrier to do this.

E.g. I happened to get sick when the series was posted, and therefore
lagged on investigation. Giving the maximum amount of window here is super
important.

> Reinette

BR, Jarkko