Binary Compatibility For SGX Enclaves

Shweta Shinde, Jinhua Cui, Satyaki Sen, Pinghai Yuan, Prateek SaxenaarXiv 2020

Abstract

Enclaves, such as those enabled by Intel SGX, offer a powerful hardware isolation primitive for application partitioning. To become universally usable on future commodity OSes, enclave designs should offer compatibility with existing software. In this paper, we draw attention to 5 design decisions in SGX that create incompatibility with existing software. These represent concrete starting points, we hope, for improvements in future TEEs. Further, while many prior works have offered partial forms of compatibility, we present the first attempt to offer binary compatibility with existing software on SGX. We present Ratel, a system that enables a dynamic binary translation engine inside SGX enclaves on Linux. Through the lens of Ratel, we expose the fundamental trade-offs between performance and complete mediation on the OS-enclave interface, which are rooted in the aforementioned 5 SGX design restrictions. We report on an extensive evaluation of Ratel on over 200 programs, including micro-benchmarks and real applications such as Linux utilities.

Introduction

Intel Software Guard Extensions (SGX) provide a trusted execution environment (TEE) designed to protect sensitive code and data from a potentially compromised operating system. Despite its security promises, SGX adoption has been hindered by significant usability challenges. The hardware breaks standard operating system abstractions such as multi-threading, signal handling, and dynamic memory mapping. Historically, developers were forced to rewrite code, use specialized languages, or relink against custom libraries like Graphene-SGX or Occlum. This "partial compatibility" remains a major barrier to adoption.

This work introduces RATEL, the first system to achieve full binary compatibility for unmodified Linux applications within SGX enclaves. RATEL aims to bridge the "last mile" of compatibility, allowing standard x86_64 binaries—such as grep, sqlite, or memcached—to run without source code modifications or build system changes.

The 5 Design Restrictions

The incompatibility between SGX and modern OSes stems from five specific hardware design restrictions (R1-R5) that affect core OS abstractions.

Table 1: OS abstractions and the SGX restrictions that affect them.

These restrictions include spatial memory partitioning (R1), static memory allocation (R2), non-shareable private memory (R3), 1-to-1 virtual mappings (R4), and fixed entry points (R5). Together, they create a significant gap between the enclave environment and standard Linux process expectations, requiring a mediation layer to restore functionality.

System Architecture: RATEL

RATEL achieves transparency through Dynamic Binary Translation (DBT). By porting the DynamoRIO framework to run entirely inside an SGX enclave, RATEL acts as an application-level virtualization layer that intercepts every instruction before execution.

Figure 1: The RATEL architecture, showing the DBT engine and its components within the enclave.

Key technical components include:

  • Two-Copy Mechanism: RATEL manages data transfer between private enclave memory and public OS memory for system calls, ensuring security while maintaining compatibility.
  • Internal Lock Management: Since SGX does not support standard Linux futex synchronization across the enclave boundary, RATEL implements an internal lock manager using hardware-backed spinlocks.
  • Signal Trampolines: Asynchronous events are handled via a primary signal handler that acts as a trampoline, redirecting execution back to the application's original handler while preserving the enclave's security state.

Evaluation

RATEL was evaluated using a diverse dataset of 203 unique unmodified binaries, including micro-benchmarks (SPEC2006, IOZone), multi-threaded workloads (Parsec-SPLASH2), and real-world applications like SQLite and Memcached.

Key Results

  • Compatibility: RATEL supports 95% of observed syscalls and successfully ran 203 binaries out-of-the-box that would otherwise require porting.
  • Library Independence: The system is agnostic to C library versions, running binaries compiled with both glibc and musl without modification.
  • Performance Overhead: CPU-bound tasks (SPEC2006) showed an average overhead of 40.24%. I/O-bound tasks saw roughly 75% slowdown due to data copying. Multi-threading overheads were the most significant (up to 832% on average) due to the switch from kernel futexes to enclave-side spinlocks.

Discussion: The "2-out-of-3" Trilemma

The development of RATEL highlights a fundamental trade-off in SGX-based systems. Developers can typically only achieve two of the following three goals: Security, Binary Compatibility, or Performance. RATEL prioritizes security and compatibility, exposing the inherent performance tax required for complete mediation on the OS-enclave interface.

Conclusion

RATEL demonstrates that full binary compatibility for SGX is possible through DBT, though it comes with a performance cost rooted in hardware design. By identifying the five core design restrictions of SGX, this work provides a roadmap for future TEE designs to better support modern operating system abstractions without sacrificing security or performance.

Summary updated

BibTeX
@misc{shinde2020binary,
  author = {Shweta Shinde and Jinhua Cui and Satyaki Sen and Pinghai Yuan and Prateek Saxena},
  title = {{Binary Compatibility For SGX Enclaves}},
  year = {2020},
  eprint = {2009.01144},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2009.01144},
}
Figure