Giter VIP home page Giter VIP logo

program-partitioning-for-security-enclaves's Introduction

program-partitioning-for-security-enclaves

Behavior based program partitioning for Intel SGX security enclaves. Partitions given program into security sensitive and insensitive partitions based on user annotations. Automatically generates Asylo code to integrate partitioned program with Asylo framework. Operates in LLVM IR level.

Dependencies

The following projects need to be built and installed in the system.

  1. nlohman json https://github.com/nlohmann/json
  2. SVF https://github.com/anahitH/SVF
  3. PDG https://github.com/anahitH/program-dependence-graph
  4. spdlog https://github.com/gabime/spdlog

For building and installing each of the mentioned projects refer to their github pages.

Build

mkdir build cd build cmake ../ make

Minimum required cmake version is 3.12

Run

Run partitioning

opt -load $SVFG_PATH -load $DG_PATH -load $PDG_PATH -load $SELF_PATH $bc -partition-analysis -json-annotations=$annots -outfile=$outfile -partition-stats

Where SVFG_PATH is the path where SVF libraries reside. PDG_PATH is the same for PDG project. SELF_PATH is the path where program partitioning library files reside. Normally this would be in the build directory. bc is the LLVM bitcode of the program to partition and annots is the json file of user annotations. The statistics of partitioning will be dumped in a file partition_stats.json.

Partitioning with optimization

The supported partition optimization methods are:

  1. no-opt - no optimization applied
  2. ilp - ILP optimization
  3. kl - Kernighan-Lin optimization
  4. search-based - optimization based on the static analysis

The default value for optimization is no-opt. In order to optimize the partition set the -optimize flag of opt. E.g.

opt -load $SVFG_PATH -load $DG_PATH -load $PDG_PATH -load $SELF_PATH $bc -partition-analysis -json-annotations=$annots -outfile=$outfile -optimize=[|ilp|kl|search-based] -partition-stats

Generating secure and insecure modules from partition

opt -load $SVFG_PATH -load $DG_PATH -load $PDG_PATH -load $SELF_PATH $bc -extract-partition -json-annotations=$annots -outfile=$outfile -optimize=[|ilp|kl|search-based] -partition-stats

Will generate two modules out of two partitions. Will add missing code to have funcional modules, e.g. setter functions for globals used and modified in both partitions.

Asylo code generation

$BIN_PATH/sgx-code-gen $SRC where BIN_PATH is where executeable sgx-code-gen resides. By default it should be in the directory build. SRC is list of source files the program constsis of. Those are source files in C and not LLVM IR.

The generated files will be:

  1. interface_selectors.h
  2. ${program_name}_enclave.cc
  3. ${program_name}_driver.cc

To generate Bazel build file for given pprogram

python scripts/generateBazelBuild.py -enclave $enclave_shared_lib_name -enclave_src $enclave.cc -enclave_lib $secure_partition.o -enclave_hdr $enclave_hdr_files -app $app_name $app_src $driver.cc -app_lib $insecure_partition.o -app_hdr $app_hdrs_files -enclaves $enclaves_name -build-template $BAZEL_build_template

Bazel build template file is in templates/BUILD_template.

program-partitioning-for-security-enclaves's People

Contributors

anahith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sandeep007734

program-partitioning-for-security-enclaves's Issues

Globals used in each partition are not updated after partition optimization

During the initial partitioning analysis each partition is assigned the set of globals it is using (modifying and/or referencing). This set needs to be updated after a partition optimization is applied, as during the optimization functions are moved between two partitions, thus the globals used in each partition may also be changed.

Associated documentation or paper

I am interested in this line of work. Can I have pointer to your thesis/publication to learn about the underlying theory/concepts?

Partition Optimization: moving function into an enclave partition

Partition Functions' optimization moves a function into a partition if this function is called from a partition only. However it is possible that moved function calls non-enclave functions in a loop. In this case it is better to leave it outside of an enclave.

This scenario can be observed for the snake game, where optimizer moves draw_line function into the partition. draw_line is called two times from enclave function, but it is calling non-enclave functions (library functions that can not be moved into an enclave) in a loop.

Running partitioned program fails

Running partitioned program with actual SGX use (no simulator) fails with the following error:

2020-02-02T18:39:16.016755Z [(H)ERROR] tid(0x7f79c35d4740) | :OE_INVALID_PARAMETER [/home/jenkins/work_dir/workspace/OpenEnclave-v0.7.x_packages/host/calls.c:oe_call_enclave_function_by_table_id:68]
Failed to invoke ecall eat_goldMakefile:13: recipe for target 'run' failed     |
make: *** [run] Error 1

Place two functions in one partition, if one is using the other to assign a callback value

Consider the following code snippet

void F(callbackType callback)
{
    int i = 13;
    if (i > 0) {
        callback = &print1;
    } else {
        callback = &print2;
    }
    callback(13);
}

there can be following cases after the partition optimization:

  1. F, print1, print2 are all in secure/insecure partitions - then we are good
  2. F is in one partition and print1 and/or print2 are in another partition
    2.1) print1/print2 do not have any use in the partition they are placed (this may not be the case if a optimization has been applied) -
    then need to move print1/print2 to the partition of F
    2.2) print1/print2 do have usage in the partition their are included in - then need to include copies of print1/print2 in the partition of F

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.