llvm-6502/test/Transforms
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
..
ADCE
AddDiscriminators
AlignmentFromAssumptions
ArgumentPromotion ArgumentPromotion: Drop sret attribute on functions that are only called directly. 2015-06-10 21:14:34 +00:00
AtomicExpand/ARM
BBVectorize Changed renaming of local symbols by inserting a dot vefore the numeric suffix. 2015-05-12 16:47:30 +00:00
BDCE
BranchFolding
CodeExtractor
CodeGenPrepare Forgot to add lit.local.cfg for new R600 directory 2015-05-26 17:01:16 +00:00
ConstantHoisting
ConstantMerge
ConstProp [ConstantFolding] Fix wrong folding of intrinsic 'convert.from.fp16'. 2015-05-14 18:01:48 +00:00
CorrelatedValuePropagation [CVP] Don't assume Constants of type i1 can be known to be true or false 2015-06-06 04:56:51 +00:00
DeadArgElim
DeadStoreElimination
EarlyCSE Correct a mistaken comment from 238071 [NFC] 2015-05-23 00:05:43 +00:00
Float2Int
FunctionAttrs Remove conflicting attributes before adding deduced readonly/readnone 2015-05-25 19:46:38 +00:00
GCOVProfiling
GlobalDCE
GlobalOpt
GVN [GVN] Use a simpler form of IRBuilder constructor. 2015-06-12 01:39:48 +00:00
IndVarSimplify Enable exitValue rewrite only when the cost of expansion is low. 2015-05-28 21:49:07 +00:00
Inline [inliner] Fix the early-exit of the inline cost analysis to correctly 2015-05-27 02:49:05 +00:00
InstCombine [InstCombine] Don't miscompile select to poison 2015-06-06 02:30:43 +00:00
InstMerge
InstSimplify [InstSimplify] fsub nnan x, x -> 0.0 is valid without ninf 2015-06-14 21:01:20 +00:00
Internalize
IPConstantProp
IRCE
JumpThreading
LCSSA
LICM [LICM] Sinking doesn't involve the preheader 2015-05-22 02:14:05 +00:00
LoadCombine
LoopDeletion
LoopDistribute [LoopAccesses] Rearrange printed lines in -analyze 2015-05-18 15:36:57 +00:00
LoopIdiom Changed renaming of local symbols by inserting a dot vefore the numeric suffix. 2015-05-12 16:47:30 +00:00
LoopInterchange
LoopReroll
LoopRotate
LoopSimplify [BasicBlockUtils] Set debug locations for instructions created in SplitBlockPredecessors. 2015-06-09 22:10:29 +00:00
LoopStrengthReduce Make the test introduced in r239015 more targeted. 2015-06-04 07:21:42 +00:00
LoopUnroll Set proper debug location for branch added in BasicBlock::splitBasicBlock(). 2015-06-11 18:25:54 +00:00
LoopUnswitch Changed renaming of local symbols by inserting a dot vefore the numeric suffix. 2015-05-12 16:47:30 +00:00
LoopVectorize [LoopVectorize] Teach Loop Vectorizor about interleaved memory accesses. 2015-06-08 06:39:56 +00:00
LowerAtomic
LowerBitSets LowerBitSets: Give names to aliases of unnamed bitset element objects. 2015-06-12 03:25:05 +00:00
LowerExpectIntrinsic
LowerInvoke
LowerSwitch Changed renaming of local symbols by inserting a dot vefore the numeric suffix. 2015-05-12 16:47:30 +00:00
Mem2Reg
MemCpyOpt [MemCpyOpt] Do move the memset, but look at its dest's dependencies. 2015-05-21 01:43:39 +00:00
MergeFunc MergeFunctions: Don't replace a weak function use by another equivalent weak function 2015-06-09 18:19:17 +00:00
MetaRenamer
NaryReassociate [NaryReassociate] Run EarlyCSE after NaryReassociate 2015-05-28 04:56:52 +00:00
ObjCARC
PartiallyInlineLibCalls
PhaseOrdering
PlaceSafepoints Add a GCStrategy for CoreCLR 2015-05-20 01:07:23 +00:00
PruneEH
Reassociate [Reassociate] Canonicalizing 'x [+-] (-Constant * y)' isn't always a win 2015-05-28 06:16:39 +00:00
Reg2Mem
RewriteStatepointsForGC [RewriteStatepointsForGC] Strip deref info after rewriting. 2015-06-02 22:33:37 +00:00
SafeStack Protection against stack-based memory corruption errors using SafeStack 2015-06-15 21:07:11 +00:00
SampleProfile Add function entry counts from sample profiles. 2015-05-13 17:04:29 +00:00
Scalarizer
ScalarRepl
SCCP
SeparateConstOffsetFromGEP SeparateConstOffsetFromGEP: Pass address space to isLegalAddressingMode 2015-06-07 20:17:44 +00:00
SimplifyCFG [Statepoints] Add test case to check that statepoint is marked with Throwable attribute. 2015-06-10 13:24:00 +00:00
Sink Teach the IR Sink pass to (conservatively) respect convergent annotations. 2015-06-01 17:20:31 +00:00
SLPVectorizer
SpeculativeExecution Add a speculative execution pass 2015-05-15 17:54:48 +00:00
SROA
StraightLineStrengthReduce SLSR: Pass address space to isLegalAddressingMode 2015-06-11 16:13:39 +00:00
StripSymbols
StructurizeCFG
TailCallElim
TailDup
Util Changed renaming of local symbols by inserting a dot vefore the numeric suffix. 2015-05-12 16:47:30 +00:00