This directory contains the source code to SPIglass, the LLVM-based implementation of Stack Pointer Integrity.
SPIglass is based on LLVM and Clang v3.7.0.
-
Verify that your system meets all requirements for LLVM, and building LLVM with CMake. We have tested these instructions on Ubuntu 14.04.1 LTS with GCC 5.4.0 and CMake 3.9.1 obtained through APT.
-
Obtain SPIglass by either downloading an archive, or by forking this repository. Once extracted, set the
SPIHOME
shell variable to the location of the top-level directory:export SPIHOME=/path/to/SPIglass
You may find it helpful to add this command to a shell configuration or startup file.
-
Checkout the necessary tagged release of Compiler-RT:
$ cd $SPIHOME/llvm-3.7.0-spi/tools $ svn co http://llvm.org/svn/llvm-project/compiler-rt/tags/RELEASE_370/final compiler-rt
-
Make a directory into which the SPIglass build will go:
$ mkdir -p $SPIHOME/build
-
Run CMake:
$ cd $SPIHOME/build $ cmake -G "Unix Makefiles" ..
-
Build SPIglass:
make -C $SPIHOME/build clang -j
You can now use the SPIglass enhanced Clang to compile executables you'd like protected:
```shell
$SPIhome/build/bin/clang -spi-align=<size> -mno-red-zone [options] input...
```
size
is the frame size alignment in bytes, and must be a power of two. In the paper, we use sizes of 128, 256, 512, 1024, and 2048.options
are the set of options available in mainstream Clang.input...
are your source files.
-
If you have not already done so, perform the SPEC CPU2006 Unix installation, steps 1-6. In particular, remember to source the directory using the
cshrc
orshrc
script. -
Add clang37-spiglass.cfg to your CPU2006 configuration files.
$ mv $SPIHOME/clang37-spiglass.cfg $SPEC/config
-
Modify the contents of clang37-spiglass.cfg configuration file:
- Lines 7-9: Set the values to reflect your hardware and operating system. This does not affect execution, but will assist you if you maintain multiple configuration files. For example:
# Compiler name/version: [SPIglass Clang/Clang++ 3.7] # Operating system version: [Ubuntu 16.04.3 LTS] # Hardware: [Dell Optiplex 9020]
- Lines 32-33: Set the absolute path to your SPIglass clang compilers:
CC = /path/to/SPIHOME/build/bin/clang CXX = /path/to/SPIHOME/build/bin/clang++
- Lines 36-64: Complete the "HWConfig" and "SWConfig" sections. This information will appear in your results, but it does not affect execution of the benchmarks.
- Lines 72-73: Set the C and C++ compiler flags, including desired frame alignment size (see Usage). For example:
COPTIMIZE = -spi-align=128 -mno-red-zone -g CXXOPTIMIZE = -spi-align=128 -mno-red-zone -g
- Lines 7-9: Set the values to reflect your hardware and operating system. This does not affect execution, but will assist you if you maintain multiple configuration files. For example:
-
Run one or more benchmarks (
bzip2
shown below) using the configuration file and SPIglass.$ runspec --config=clang37-spiglass.cfg --action=rebuild \ --tune=base --size=ref --iterations=1 --noreportable bzip2
Supplementing Modern Software Defenses with Stack-Pointer Sanity
Anh Quach, Matthew Cole and Aravind Prakash.
Annual Computer Security Applications Conference (ACSAC'17), Orlando, FL, December 2017.
Full Paper