一句话:CGuard 在 x86_64 上实现精确对象边界保护,突破 SGXBounds 的 32 位地址空间限制且开销相当。
空间安全违规是许多安全攻击和应用异常行为的根源。现有空间安全保护技术分为对象粒度和指针粒度:对象粒度方案 CPU 开销高,指针粒度方案 CPU 和内存开销都高。SGXBounds 作为对象粒度方案,能以较低开销提供精确越界保护,但无法支持大于 32 位的地址空间。本文提出 CGuard,在不限制应用地址空间的前提下提供精确对象边界保护,开销与 SGXBounds 相当。CGuard 将边界信息存储在对象基地址之前,并利用 x86_64 虚拟地址中的空闲位编码基地址相对偏移;对于无法编码的大对象,采用定制内存布局,仅需一次内存访问即可找到基地址。评估在 SPEC CPU2017、Phoenix 和 Apache 上进行,发现了 gcc、x264 和 string_match 中的空间安全违规;SPEC CPU2017 与 Phoenix 的执行时间开销分别为 42% 和 26%,Apache 在 CPU 满载时吞吐下降 30%。
Spatial safety violations are the root cause of many security attacks and unexpected behavior of applications. Existing techniques to enforce spatial safety work broadly at either object or pointer granularity. Object-based approaches tend to incur high CPU overheads, whereas pointer-based approaches incur both high CPU and memory overheads. SGXBounds, an object-based approach, provides precise out-of-bounds protection for objects at a lower overhead compared to other tools with similar precision. However, a major drawback of this approach is that it cannot support address space larger than 32-bit. In this paper, we present CGuard, a tool that provides precise object-bounds protection for C applications with comparable overheads to SGXBounds without restricting the application address space. CGuard stores the bounds information just before the base address of an object and encodes the relative offset of the base address in the spare bits of the virtual address available in x86_64 architecture. For an object that cannot fit in the spare bits, CGuard uses a custom memory layout that enables it to find the base address of the object in just one memory access. Our study revealed spatial safety violations in the gcc and x264 benchmarks from the SPEC CPU2017 benchmark suite and the string_match benchmark from the Phoenix benchmark suite. The execution time overheads for the SPEC CPU2017 and Phoenix benchmark suites were 42% and 26% respectively, whereas the reduction in the throughput for the Apache webserver when the CPUs were fully saturated was 30%. These results indicate that CGuard can be highly effective while maintaining a reasonable degree of efficiency.