CAMP: Compiler and Allocator-based Heap Memory Protection | |
---|---|
Author | Zhenpen Lin, Zheng Yu, Ziyi Guo, Simone Campanoni, Peter Dinda, Xinyu Xing |
Institution | Northwestern University |
Conference | USENIX Security |
Year | 2024 |
개요
Compiler support와 Memory allocator support를 이용해서 Memory santizier을 개발하였다. Memory allocator을 통한 Runtime-support로 다양한 Static instrumentation optimization을 통해서 overhead를 줄였다.
Motivation & Importance
ASAN과 같은 Memory santizier들은 Effective하지만 Performance가 좋지 못하다. FFmalloc, Oscar과 같은 프로젝트들은 Performance는 좋지만 Tempoar, Spatial둘다 Detect하지 못한다. 따라서 Temporal, Spatial둘다 고려하면서 성능적으로 우수한 Memory sanitizer를 개발하는 것이 중요하다.
Design
- Compiler Support
- 컴파일러는 Runtime에서 사용할 Pointer tracking을 위한 Escape tracking구문과, Range checking을 위한 구문을 삽입한다. 이떄 Range checking은 Load/store operation이 아니라 Pointer arithmetic에서 수행된다.
- Allocoator Design
- Allocator는 span단위로 free-list를 가지고 있으며, 각 span마다 escape table이라 불리는, 누가 누구를 Reference하는지 관리하는 list를 가진다. Free시점에서 이 escape table를 가지고 Pointer nullification이 진행하여서, Temporal bug가 일어나지 않도록 하였다.
- Compiler Optimization
Temporal safety에 대한 걱정이 없기 때문에 좀더 Aggressive한 Compiler optimization을 적용가능하다.
- Optimizing range checks with type information: Type으로 Range정보를 유추해서 Static time에 range정보를 알 수 있을 경우 생략
- Removing redundant instructions: Range checking이 겹치는 경우 생략하였다.
- Merging runtime calls: 함수를 부를때, 만약 같은 Range checking으로 한번만 수행할 수 있으면 생략하였다.
Evaluation
SPEC CPU 2006에서 비교시 다음과 같은 오버헤드가 발생하였다.
CAMP | LowFat | Delta Pointers | DangNull | FreeGuard | MarkUs | FFmalloc | |
---|---|---|---|---|---|---|---|
Time | 54.92 | 160.62 | 37.39 | 39.99 | 10.40 | 15.84 | 9.50 |
Memory | 237.67 | 38.60 | 0.01 | 158.52 | 70.89 | 2.96 | 27.57 |
Conclusion
이 연구의 가장 큰 장점은 메모리 할당자(Memory allocator)와 컴파일러 계측(Compiler instrumentation)의 기능을 분리하고, 그에 따른 최적화 가능성을 제시함으로써 관련 연구의 지평을 넓혔다는 점이다.
하지만 몇 가지 한계점 또한 분명하다. 우선 Integer-to-pointer 캐스팅을 지원하지 않아 호환성 측면에서 문제가 될 수 있다는 점이다. 또한 ASan(AddressSanitizer)과 달리 검증 범위가 힙(Heap) 영역에만 국한되어 스택(Stack)과 같은 영역은 검증하지 못하는 한계이며, 나아가 포인터 연산(Pointer arithmetic) 시에만 범위 검사를 수행하므로 모든 공간적 오류(Spatial bug)를 탐지할 수는 없다는 탐지 능력의 한계이다. 컴파일러 최적화 관련 내용은 기존 ASan 최적화 연구Debloating Address Sanitizer와 중복되는 부분이 많아 독창성이 부족하다는 점이며, SPEC CPU 2006 벤치마크 결과에서도 ASan의 오버헤드(56.77%)와 비교했을 때 뚜렷한 성능적 우위를 보여주지 못했다는 점이다. 마지막으로, 논문의 Table 2에서 UAF(Use-After-Free)와 시간적 안전성(Temporal safety)을 각기 다른 기호로 표기하여 해석의 직관성을 떨어뜨린다는 점도 아쉬운 부분이다.