一句话:复用 Intel MPX 的边界元数据来同时提供空间与时间安全,以低开销实现完整内存安全。
内存安全违规包括越界访问(空间安全)与释放后使用(时间安全)。Intel 的 Memory Protection Extensions(MPX)提供硬件加速的边界检查,但只保证空间安全,不提供时间安全。本文提出 BOGO,一个透明的轻量级完整内存安全方案:它在 MPX 的空间安全之上补充时间安全,而不维护额外的元数据,而是复用 MPX 已有的边界元数据。在 free 时,BOGO 扫描 MPX 边界表并使悬垂指针的边界失效,此后对悬垂指针的使用会被 MPX 直接报告为越界错误。由于全表扫描代价过高,BOGO 只跟踪少量热 MPX 边界表页在 free 时检查,并借助页错误机制捕获可能漏掉的悬垂指针,从而保证时间安全保护的可靠性(soundness)。在 SPEC CPU 2006 基准上,BOGO 以 60% 运行时开销与 36% 内存开销提供完整内存安全;在最坏情况下 malloc/free 密集的基准上为 2.7 倍减速,对真实应用仅有约 1.34 倍开销。
A memory safety violation occurs when a program has an out-of-bound (spatial safety) or use-after-free (temporal safety) memory access. Given its importance as a security vulnerability, recent Intel processors support hardware-accelerated bound checks, called Memory Protection Extensions (MPX). Unfortunately, MPX provides no temporal safety. This paper presents BOGO, a lightweight full memory safety enforcement scheme that transparently guarantees temporal safety on top of MPX's spatial safety. Instead of tracking separate metadata for temporal safety, BOGO reuses the bounds metadata maintained by MPX for both spatial and temporal safety. On free, BOGO scans the MPX bound tables to invalidate the bound of dangling pointers; any following use-after-free error can be detected by MPX as an out-of-bound error. Since scanning the entire MPX bound tables could be expensive, BOGO tracks a small set of hot MPX bound table pages to check on free, and relies on the page fault mechanism to detect any potentially missing dangling pointer, ensuring sound temporal safety protection. Our evaluation shows that BOGO provides full memory safety at 60% runtime overhead and at 36% memory overhead for SPEC CPU 2006 benchmarks. We also show that BOGO incurs reasonable 2.7x slowdown for the worst-case malloc-free intensive benchmarks; and moderate 1.34x overhead for real-world applications.