On Fri, Aug 09, 2024 at 11:19:22AM +0000, Huang, Kai wrote: > > TLDR: I can add similar handling to sgx_enclave_modify_types() if > > reviewers insist, but I don't see how this data race can ever be > > triggered by benign real-world SGX applications. > > So as mentioned above, I intend to suggest to also apply the BUSY flag here. > And we can have a consist rule in the kernel: > > If an enclave page is under certainly operation by the kernel with the mapping > removed, other threads trying to access that page are temporarily blocked and > should retry. I agree with your assessment on the consequences of such bug in sgx_enclave_modify_types(). To my understanding, this bug can only affect the SGX enclave (i.e. the userspace) -- either the SGX enclave will hang or will be terminated. Anyway, I will apply the BUSY flag also in sgx_enclave_modify_types() in the next iteration of this patch series. -- Dmitrii Kuvaiskii