An Investigation into the Security of Register Allocation with Spilling and Splitting
Priyanka Panigrahi, Chandan Karfa · 2023
Compiler optimization can be functionally correct but not secure. Register allocation (RA) is an essential optimization performed by a compiler. This paper analyzes the security threat of RA concerning information flow. We define the relative security between two programs with respect to information flow. According to our definition of relative security, we show that RA is secure when there is no splitting and spilling into memory. We also show that register allocation with splitting is also secure based on our attack model. Then, we show that RA can lead to information leaks during spilling as it introduces new leaks through memory. Further, our experimental results on various benchmarks show that RA in LLVM is actually leaky. To address this vulnerability, we propose a secure RA approach in LLVM that mitigates the risk of new leaks during spilling. Our experimental evaluation on various benchmarks shows the effectiveness of our proposed approach.