llvm-6502/include/llvm/IR
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
..
Argument.h Add missing dereferenceable_or_null getters 2015-05-06 17:41:54 +00:00
AssemblyAnnotationWriter.h
Attributes.h Protection against stack-based memory corruption errors using SafeStack 2015-06-15 21:07:11 +00:00
AutoUpgrade.h
BasicBlock.h [PlaceSafepoints] Cleanup InsertSafepointPoll function 2015-05-26 21:03:23 +00:00
CallingConv.h
CallSite.h Add missing dereferenceable_or_null getters 2015-05-06 17:41:54 +00:00
CFG.h Fix the build broken in r231142 2015-03-03 21:56:11 +00:00
CMakeLists.txt
Comdat.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
Constant.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
ConstantFolder.h [opaque pointer types] Push explicit type parameter for geps through the constant folders 2015-04-03 01:15:16 +00:00
ConstantRange.h [ConstantRange] Split makeICmpRegion in two. 2015-03-18 00:41:24 +00:00
Constants.h 80-col fixup. 2015-05-18 22:12:43 +00:00
DataLayout.h COFF: Let globals with private linkage reside in their own section 2015-03-17 23:54:51 +00:00
DebugInfo.h IR: Give 'DI' prefix to debug info metadata 2015-04-29 16:38:44 +00:00
DebugInfoFlags.def IR: Move DebugInfo Flag* definitions to .def file, NFC 2015-02-21 00:37:53 +00:00
DebugInfoMetadata.h IR / debug info: Add a DWOId field to DICompileUnit, 2015-05-21 20:37:30 +00:00
DebugLoc.h IR: Give 'DI' prefix to debug info metadata 2015-04-29 16:38:44 +00:00
DerivedTypes.h Extract the load/store type verification to a separate function. 2015-05-18 21:48:55 +00:00
DiagnosticInfo.h MIR Serialization: Connect the machine function analysis pass to the MIR parser. 2015-06-15 20:30:22 +00:00
DiagnosticPrinter.h MIR Serialization: Connect the machine function analysis pass to the MIR parser. 2015-06-15 20:30:22 +00:00
DIBuilder.h IR / debug info: Add a DWOId field to DICompileUnit, 2015-05-21 20:37:30 +00:00
Dominators.h
Function.h Add initial support for the convergent attribute. 2015-05-26 23:48:40 +00:00
GetElementPtrTypeIterator.h [opaque pointer type] Allow gep_type_iterator to work with the pointee type from the GEP instruction 2015-05-21 21:12:43 +00:00
GlobalAlias.h [opaque pointer type] Pass GlobalAlias the actual pointer type rather than decomposing it into pointee type + address space 2015-04-29 21:22:39 +00:00
GlobalObject.h Add some type safety to GlobalObject/GlobalValue - they're always PointerTypes so let's type them that way. 2015-04-06 18:06:06 +00:00
GlobalValue.h Replace magic number 19 with the constant GlobalValueSubClassDataBits. 2015-06-10 06:00:59 +00:00
GlobalVariable.h Rename NumOperands to make it clear its managed by the User. NFC. 2015-06-12 17:48:10 +00:00
GVMaterializer.h While in GlobalValue fix the function(s) that don't follow the 2015-05-15 18:20:14 +00:00
InlineAsm.h [arm] Distinguish the /U[qytnms]/, 'Uv', 'Q', and 'm' inline assembly memory constraints. 2015-06-03 12:33:56 +00:00
InstIterator.h Fix uses of reserved identifiers starting with an underscore followed by an uppercase letter 2015-03-16 18:06:57 +00:00
InstrTypes.h Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00
Instruction.def
Instruction.h [PlaceSafepoints] Cleanup InsertSafepointPoll function 2015-05-26 21:03:23 +00:00
Instructions.h Added a version of User::new for hung off uses. 2015-06-12 17:48:14 +00:00
InstVisitor.h Change Function::getIntrinsicID() to return an Intrinsic::ID. NFC. 2015-05-20 17:16:39 +00:00
IntrinsicInst.h Change Function::getIntrinsicID() to return an Intrinsic::ID. NFC. 2015-05-20 17:16:39 +00:00
Intrinsics.h Store intrinsic ID by value in Function instead of a string lookup. NFC. 2015-05-19 00:24:26 +00:00
Intrinsics.td [WinEH] Create an llvm.x86.seh.exceptioninfo intrinsic 2015-06-11 22:32:23 +00:00
IntrinsicsAArch64.td
IntrinsicsARM.td
IntrinsicsBPF.td [bpf] add support for bpf pseudo instruction 2015-03-27 18:51:42 +00:00
IntrinsicsHexagon.td [Hexagon] Intrinsics for circular and bit-reversed loads and stores 2015-03-18 16:23:44 +00:00
IntrinsicsMips.td
IntrinsicsNVVM.td
IntrinsicsPowerPC.td LLVM support for vector quad bit permute and gather instructions through builtins 2015-06-11 06:21:25 +00:00
IntrinsicsR600.td
IntrinsicsSystemZ.td [SystemZ] Add vector intrinsics 2015-05-05 19:31:09 +00:00
IntrinsicsX86.td AVX-512: Implemented cvtsi2ss/d cvtusi2ss/d instructions with round control for KNL. 2015-06-14 12:44:55 +00:00
IntrinsicsXCore.td
IRBuilder.h [opaque pointer type] Pass explicit type to Load instruction creation in AutoUpgrade 2015-05-20 21:46:30 +00:00
IRPrintingPasses.h uselistorder: Pull the bit through PrintModulePass 2015-04-15 02:38:06 +00:00
LegacyPassManager.h Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00
LegacyPassManagers.h
LegacyPassNameParser.h Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00
LLVMContext.h Dereferenceable, dereferenceable_or_null metadata for loads 2015-05-19 20:10:19 +00:00
Mangler.h Revert "Address review comments" 2015-03-17 20:40:21 +00:00
MDBuilder.h Add isConstant argument to MDBuilder::createTBAAStructTagNode 2015-06-01 14:53:55 +00:00
Metadata.def IR: Give 'DI' prefix to debug info metadata 2015-04-29 16:38:44 +00:00
Metadata.h IR: Give 'DI' prefix to debug info metadata 2015-04-29 16:38:44 +00:00
MetadataTracking.h
Module.h Replace duplicated iplist<T> types with the corresponding typedefs. 2015-06-12 08:19:32 +00:00
NoFolder.h [opaque pointer types] Push explicit type parameter for geps through the constant folders 2015-04-03 01:15:16 +00:00
OperandTraits.h Replace all accesses to User::OperandList with getter and setter methods. NFC. 2015-06-12 17:48:05 +00:00
Operator.h [opaque pointer type] Allow gep_type_iterator to work with the pointee type from the GEP instruction 2015-05-21 21:12:43 +00:00
PassManager.h Remove std::move on return of temporary. 2015-05-01 15:26:22 +00:00
PassManagerInternal.h Revert r238305: [PM] Use a simpler technique to drop optional analysis 2015-05-27 09:36:33 +00:00
PatternMatch.h [InstCombine][CodeGenPrep] Create llvm.uadd.with.overflow in CGP. 2015-04-10 21:07:09 +00:00
PredIteratorCache.h Revamp PredIteratorCache interface to be cleaner. 2015-04-21 21:11:50 +00:00
Statepoint.h [Statepoints] Support for "patchable" statepoints. 2015-05-12 23:52:24 +00:00
SymbolTableListTraits.h
TrackingMDRef.h
Type.h Add the i128 builtin type to LLVM. 2015-04-17 15:32:15 +00:00
TypeBuilder.h Update comment. NFC. 2015-04-21 21:15:35 +00:00
TypeFinder.h
Use.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
UseListOrder.h uselistorder: Remove the global bits 2015-04-15 03:14:06 +00:00
User.h Remove a bunch of inline keywords from User. NFC. 2015-06-12 17:48:21 +00:00
Value.h Rename NumOperands to make it clear its managed by the User. NFC. 2015-06-12 17:48:10 +00:00
ValueHandle.h Revert "Remove the explicit SDNodeIterator::operator= in favor of the implicit default" 2015-03-03 21:18:16 +00:00
ValueMap.h [Mips] Use unique_ptr to manage ownership. 2015-04-16 12:43:33 +00:00
ValueSymbolTable.h
Verifier.h Verifier: Remove the separate -verify-di pass 2015-03-19 22:24:17 +00:00