一句话:提出段折叠阴影编码,提高内存消毒保护密度并显著降低运行时开销。
基于位置的内存消毒方法兼容性好,但保护密度低:单个元数据守护的字节数有限,导致大量访存需要加载过多元数据,运行时开销高。本文提出段折叠(segment folding)阴影编码,将具有相同元数据的相邻字节汇总为折叠段,从而减少不必要的元数据加载,用更少元数据保护大块内存。作者实现 GiantSan,并在 SPEC CPU 2017 上评估:其运行时开销分别比 ASan 和 ASan- 低 59.10% 与 38.52%;在同一 redzone 设置下,测试真实项目 PHP 时比二者少 463 个假阴性。
Memory safety sanitizers, the sharp weapon for detecting invalid memory operations during execution, employ runtime metadata to model the memory and help find memory errors hidden in the programs. However, location-based methods, the most widely deployed memory sanitization methods thanks to their high compatibility, face the low protection density issue: the number of bytes safeguarded by one metadata is limited. As a result, numerous memory accesses require loading excessive metadata, leading to a high runtime overhead. To address this issue, we propose a new shadow encoding with segment folding to increase the protection density. Specifically, we characterize neighboring bytes with identical metadata by building novel summaries, called folded segments, on those bytes to reduce unnecessary metadata loadings. The new encoding uses less metadata to safeguard large memory regions, speeding up memory sanitization. We implement our designed technique as GiantSan. Our evaluation using the SPEC CPU 2017 benchmark shows that GiantSan outperforms the state-of-the-art methods with 59.10% and 38.52% less runtime overhead than ASan and ASan-, respectively. Moreover, under the same redzone setting, GiantSan detects 463 fewer false negative cases than ASan and ASan- in testing the real-world project PHP.