llvm-6502/include/llvm
Peter Collingbourne 7ffec838a2 Protection against stack-based memory corruption errors using SafeStack
This patch adds the safe stack instrumentation pass to LLVM, which separates
the program stack into a safe stack, which stores return addresses, register
spills, and local variables that are statically verified to be accessed
in a safe way, and the unsafe stack, which stores everything else. Such
separation makes it much harder for an attacker to corrupt objects on the
safe stack, including function pointers stored in spilled registers and
return addresses. You can find more information about the safe stack, as
well as other parts of or control-flow hijack protection technique in our
OSDI paper on code-pointer integrity (http://dslab.epfl.ch/pubs/cpi.pdf)
and our project website (http://levee.epfl.ch).

The overhead of our implementation of the safe stack is very close to zero
(0.01% on the Phoronix benchmarks). This is lower than the overhead of
stack cookies, which are supported by LLVM and are commonly used today,
yet the security guarantees of the safe stack are strictly stronger than
stack cookies. In some cases, the safe stack improves performance due to
better cache locality.

Our current implementation of the safe stack is stable and robust, we
used it to recompile multiple projects on Linux including Chromium, and
we also recompiled the entire FreeBSD user-space system and more than 100
packages. We ran unit tests on the FreeBSD system and many of the packages
and observed no errors caused by the safe stack. The safe stack is also fully
binary compatible with non-instrumented code and can be applied to parts of
a program selectively.

This patch is our implementation of the safe stack on top of LLVM. The
patches make the following changes:

- Add the safestack function attribute, similar to the ssp, sspstrong and
  sspreq attributes.

- Add the SafeStack instrumentation pass that applies the safe stack to all
  functions that have the safestack attribute. This pass moves all unsafe local
  variables to the unsafe stack with a separate stack pointer, whereas all
  safe variables remain on the regular stack that is managed by LLVM as usual.

- Invoke the pass as the last stage before code generation (at the same time
  the existing cookie-based stack protector pass is invoked).

- Add unit tests for the safe stack.

Original patch by Volodymyr Kuznetsov and others at the Dependable Systems
Lab at EPFL; updates and upstreaming by myself.

Differential Revision: http://reviews.llvm.org/D6094

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239761 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-15 21:07:11 +00:00
..
ADT Add 'shave' processor name to Triple 2015-06-12 18:31:38 +00:00
Analysis [LAA] Fix estimation of number of memchecks 2015-06-08 10:27:06 +00:00
AsmParser
Bitcode Protection against stack-based memory corruption errors using SafeStack 2015-06-15 21:07:11 +00:00
CodeGen MIR Serialization: Connect the machine function analysis pass to the MIR parser. 2015-06-15 20:30:22 +00:00
Config [omp] Add a configuration variable for the default OpenMP runtime. 2015-05-28 01:47:22 +00:00
DebugInfo Re-unique_ptrify LoadedObjectInfo::clone after it was reverted due to some other changes that broke on GCC around the same time 2015-06-04 20:54:32 +00:00
ExecutionEngine [ExecutionEngine] ArrayRefize argument passing. 2015-06-13 19:50:29 +00:00
IR Protection against stack-based memory corruption errors using SafeStack 2015-06-15 21:07:11 +00:00
IRReader
LibDriver LibDriver, llvm-lib: introduce. 2015-06-09 21:50:22 +00:00
LineEditor Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00
Linker Linker: Add flag to override linkage rules 2015-04-22 04:11:00 +00:00
LTO Make the C++ LTO API easier to use from C++ clients. 2015-06-01 20:08:30 +00:00
MC [CodeGen] Introduce a FAULTING_LOAD_OP pseudo-op. 2015-06-15 18:44:08 +00:00
Object Avoid a "always true" warning from gcc. 2015-06-15 14:49:41 +00:00
Option Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00
Passes [PM] Create a separate library for high-level pass management code. 2015-03-07 09:02:36 +00:00
ProfileData Tidy comments in SampleProfile header. NFC. 2015-05-12 22:03:00 +00:00
Support MIR Serialization: Connect the machine function analysis pass to the MIR parser. 2015-06-15 20:30:22 +00:00
TableGen [TableGen] Use the SMLoc header file instead of SourceMgr header file in a couple places. NFC 2015-06-08 01:35:40 +00:00
Target MIR Serialization: Connect the machine function analysis pass to the MIR parser. 2015-06-15 20:30:22 +00:00
Transforms Protection against stack-based memory corruption errors using SafeStack 2015-06-15 21:07:11 +00:00
CMakeLists.txt
InitializePasses.h Protection against stack-based memory corruption errors using SafeStack 2015-06-15 21:07:11 +00:00
LinkAllIR.h
LinkAllPasses.h Protection against stack-based memory corruption errors using SafeStack 2015-06-15 21:07:11 +00:00
module.modulemap Fix modules build post-r235612. 2015-04-23 23:22:26 +00:00
module.modulemap.build
Pass.h Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00
PassAnalysisSupport.h Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for requiring the macro. NFC; LLVM edition. 2015-02-15 22:54:22 +00:00
PassInfo.h Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for requiring the macro. NFC; LLVM edition. 2015-02-15 22:54:22 +00:00
PassRegistry.h Revert r231276 (including r231277): Add a lock() function in PassRegistry to speed up multi-thread synchronization. 2015-03-05 17:53:00 +00:00
PassSupport.h