Skip to content

Commit

Permalink
Merge pull request #1 from jcape/feature/panic-abort
Browse files Browse the repository at this point in the history
Repo Setup and Aborting Panic Handler
  • Loading branch information
James Cape authored Aug 16, 2021
2 parents cd80d64 + 40838d7 commit 6b64bf3
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
24 changes: 24 additions & 0 deletions .github/workflows/cargo-audit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: cargo-audit
on:
pull_request:
paths: Cargo.lock
push:
branches: develop
paths: Cargo.lock
schedule:
- cron: "0 0 * * *"

jobs:
security_audit:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Cache cargo bin
uses: actions/cache@v1
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-audit-v0.12
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/panic-abort.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: panic-abort

on:
pull_request:
paths:
- "panic/abort/**"
- "Cargo.*"

defaults:
run:
working-directory: "panic/abort"

env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Dwarnings"

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
- nightly-2021-07-21
- nightly
target:
- x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
profile: minimal
- run: cargo build --release --target ${{ matrix.target }}

36 changes: 36 additions & 0 deletions .github/workflows/workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Workspace
on:
pull_request:
paths-ignore:
- README.md

env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Dwarnings"

jobs:
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt
override: true
profile: minimal
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: clippy
override: true
profile: minimal
- run: cargo clippy --all --all-features -- -D warnings
22 changes: 22 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[workspace]
resolver = "2"
members = [
"panic/abort",
]

[profile.dev]
opt-level = 0
rpath = true
lto = true

[profile.release]
opt-level = 3
rpath = false
lto = true
debug-assertions = false
overflow-checks = false

# Skip the need for LD_LIBRARY_PATH in `cargo test`
[profile.test]
rpath = true

6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# sgx
# MobileCoin SGX

SGX Libraries and Utilities

[![dependency status](https://deps.rs/repo/github/mobilecoinfoundation/sgx/status.svg)](https://deps.rs/repo/github/mobilecoinfoundation/sgx)

14 changes: 14 additions & 0 deletions panic/abort/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "mc-sgx-panic-abort"
version = "0.1.0"
authors = ["MobileCoin"]
description = "Aborting panic handler for Intel-SGX enclaves."
edition = "2018"
repository = "https://github.com/mobilecoinfoundation/sgx.git"
license = "GPLv3"
keywords = ["no-std", "sgx", "mobilecoin", "panic-handler"]
categories = ["hardware-support", "api-bindings"]
readme = "README.md"

[badges]
maintenance = { status = "actively-developed" }
29 changes: 29 additions & 0 deletions panic/abort/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# MobileCoin SGX: Panic-Abort

Aborting panic handler for Intel-SGX enclaves.

[![crate][crate-image]][crate-link]
[![Docs][docs-image]][docs-link]
![GPLv3.0 Licensed][license-image]
![Rust Version][rustc-image]
[![Project Chat][chat-image]][chat-link]
[![Crates.io Downloads][downloads-image]][crate-link]
[![Build Status][build-image]][build-link]

This crate provides a panic handler implementation intended to be executed inside an SGX enclave. Specifically, it will provide the required `rust_eh_personality()` and `#![panic_handler]` methods to satisfy the linker for a `#![no_std]` environment. As a result, this crate will

This crate currently requires independent linkage to the `libsgx_trts.a` library, which provides the `abort()` call we use to mark the enclave dead. The goal for all crates in this repository is to handle the intricate linkage requirements of the Intel SGX SDK automagically, but that is not in place yet, so users of this crate will need to link it themselves for now.

[//]: # (badges)

[crate-image]: https://img.shields.io/crates/v/mc-sgx-panic-abort?style=for-the-badge
[crate-link]: https://crates.io/crates/mc-sgx-panic-abort
[docs-image]: https://img.shields.io/docsrs/mc-sgx-panic-abort/latest?style=for-the-badge
[docs-link]: https://docs.rs/mc-sgx-panic-abort/
[license-image]: https://img.shields.io/github/license/mobilecoinfoundation/sgx?style=for-the-badge
[rustc-image]: https://img.shields.io/badge/rustc-nightly-orange.svg?style=for-the-badge&logo=rust
[chat-image]: https://img.shields.io/discord/844353360348971068.svg?style=for-the-badge
[chat-link]: https://discord.gg/4kP8ftbVfA
[downloads-image]: https://img.shields.io/crates/d/mc-sgx-panic-abort.svg?style=for-the-badge
[build-image]: https://img.shields.io/github/workflow/status/mobilecoinfoundation/sgx/panic-abort?style=for-the-badge
[build-link]: https://github.com/mobilecoinfoundation/sgx/actions
29 changes: 29 additions & 0 deletions panic/abort/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2021 MobileCoin Foundation

#![doc = include_str!("../README.md")]
#![no_std]
#![feature(lang_items)]

use core::panic::PanicInfo;

/// The panic implementation.
///
/// This is required by no_std libraries (on the rust side), and calls
/// `abort()` in a previously imported `libsgx_tcxx.a` (on the SGX side).
#[lang = "panic_impl"]
#[no_mangle]
pub extern "C" fn panic(_info: &PanicInfo) -> ! {
extern "C" {
fn abort() -> !;
}

unsafe { abort() }
}

/// Exception Handling Personality Language Item.
///
/// This is required to inject panic-handling into an application with only
/// libcore support.
#[lang = "eh_personality"]
#[no_mangle]
pub extern "C" fn rust_eh_personality() {}
3 changes: 3 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
edition = "2018"
wrap_comments = true
imports_granularity = "Crate"

0 comments on commit 6b64bf3

Please sign in to comment.