Preventing Dangling Pointers with Intermediate Pointers
Existing runtime protection methods that prevent attacks based on dangling pointer incur high runtime overhead and memory overhead.
We design a lightweight approach to eliminate dangling pointers during the compilation time. We first develop a static dangling pointer checker based on Clang to detect potential dangling pointers if the pointers are deallocated but not nullified. Then, we transform the potential dangling pointers so that all aliases of a pointer point to the same intermediate pointer. When all aliases point to the same pointer, all dangling pointers are eliminated if the intermediate pointer points to null.