Visible to the public What You Get is What You C: Controlling Side Effects in Mainstream C Compilers

TitleWhat You Get is What You C: Controlling Side Effects in Mainstream C Compilers
Publication TypeConference Paper
Year of Publication2018
AuthorsSimon, Laurent, Chisnall, David, Anderson, Ross
Conference Name2018 IEEE European Symposium on Security and Privacy (EuroS P)
KeywordsC, C abstract machine, C++ language, careful programmer, Clang, compiler commands, Compiler Optimization, compiler optimizations, compiler performance, compiler security, compiler upgrade, compiler writers, compilers, compositionality, constant-time, CPUs, crypto code, cryptographic algorithm, cryptographic protocol security, cryptographic protocols, cryptography, erasing, implicit properties, language security, Libraries, LLVM, mainstream C compilers, Metrics, optimisation, Optimization, program compilers, Program processors, program verification, pubcrawl, Resiliency, Scalability, secure code, Security Engineers, security properties, side channels, side effects, stack, Standards, Timing, timing channel, zeroing
AbstractSecurity engineers have been fighting with C compilers for years. A careful programmer would test for null pointer dereferencing or division by zero; but the compiler would fail to understand, and optimize the test away. Modern compilers now have dedicated options to mitigate this. But when a programmer tries to control side effects of code, such as to make a cryptographic algorithm execute in constant time, the problem remains. Programmers devise complex tricks to obscure their intentions, but compiler writers find ever smarter ways to optimize code. A compiler upgrade can suddenly and without warning open a timing channel in previously secure code. This arms race is pointless and has to stop. We argue that we must stop fighting the compiler, and instead make it our ally. As a starting point, we analyze the ways in which compiler optimization breaks implicit properties of crypto code; and add guarantees for two of these properties in Clang/LLVM. Our work explores what is actually involved in controlling side effects on modern CPUs with a standard toolchain. Similar techniques can and should be applied to other security properties; achieving intentions by compiler commands or annotations makes them explicit, so we can reason about them. It is already understood that explicitness is essential for cryptographic protocol security and for compiler performance; it is essential for language security too. We therefore argue that this should be only the first step in a sustained engineering effort.
DOI10.1109/EuroSP.2018.00009
Citation Keysimon_what_2018