Insert random noops to increase security against ROP attacks (llvm)
authorJF Bastien <jfb@google.com>
Wed, 14 Jan 2015 01:07:26 +0000 (01:07 +0000)
committerJF Bastien <jfb@google.com>
Wed, 14 Jan 2015 01:07:26 +0000 (01:07 +0000)
commit21befa7761c9e0983a85603ec0ec35e58441fadf
treeccc7d52873b3e8e7b54ec5170f058259ea859f54
parent7a4708e0eb025148a872f5de2d1e6c51483615ff
Insert random noops to increase security against ROP attacks (llvm)

A pass that adds random noops to X86 binaries to introduce diversity with the goal of increasing security against most return-oriented programming attacks.

Command line options:
  -noop-insertion // Enable noop insertion.
  -noop-insertion-percentage=X // X% of assembly instructions will have a noop prepended (default: 50%, requires -noop-insertion)
  -max-noops-per-instruction=X // Randomly generate X noops per instruction. ie. roll the dice X times with probability set above (default: 1). This doesn't guarantee X noop instructions.

In addition, the following 'quick switch' in clang enables basic diversity using default settings (currently: noop insertion and schedule randomization; it is intended to be extended in the future).
  -fdiversify

This is the llvm part of the patch.
clang part: D3393

http://reviews.llvm.org/D3392
Patch by Stephen Crane (@rinon)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225908 91177308-0d34-0410-b5e6-96231b3b80d8
17 files changed:
include/llvm/CodeGen/CommandFlags.h
include/llvm/CodeGen/NoopInsertion.h [new file with mode: 0644]
include/llvm/CodeGen/Passes.h
include/llvm/InitializePasses.h
include/llvm/Support/RandomNumberGenerator.h
include/llvm/Target/TargetInstrInfo.h
include/llvm/Target/TargetOptions.h
lib/CodeGen/CMakeLists.txt
lib/CodeGen/CodeGen.cpp
lib/CodeGen/NoopInsertion.cpp [new file with mode: 0644]
lib/CodeGen/Passes.cpp
lib/Target/X86/X86InstrInfo.cpp
lib/Target/X86/X86InstrInfo.h
test/CodeGen/Mips/noop-insert.ll [new file with mode: 0644]
test/CodeGen/PowerPC/noop-insert.ll [new file with mode: 0644]
test/CodeGen/X86/noop-insert-percentage.ll [new file with mode: 0644]
test/CodeGen/X86/noop-insert.ll [new file with mode: 0644]