edgelesssys / edgelessrt

Edgeless RT is an SDK and a runtime for Intel SGX. It combines top-notch Go support with simplicity, robustness and a small TCB. Developing confidential microservices has never been easier! C++17 and Rust (experimental) are also supported.
https://edgeless.systems
MIT License
130 stars 20 forks source link

fix crash on enclave termination on Ubuntu 22.04 #152

Closed thomasten closed 1 year ago

thomasten commented 1 year ago

glibc >= 2.34 has a new implementation of pthread_cancel. It now always uses the fs register. (Previously, it did so only in situations not affecting us.) OE swaps fs when entering the enclave in simulation mode. If a thread is then canceled, it causes a segfault.

To fix this, only call pthread_cancel when the target thread is in an ocall. Let the target thread check for a cancelation request while it was inside the enclave.

Changes (I suggest looking at corresponding commits separately)