Skip to content

Commit ca2b679

Browse files
committed
Detect possible ABI change issues in the runner
1 parent 52c797d commit ca2b679

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

intel-sgx/enclave-runner/src/loader.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ impl<'a> EnclaveBuilder<'a> {
278278
self
279279
}
280280

281+
pub fn forced_insecure_time_usercalls(&self) -> bool {
282+
self.force_time_usercalls
283+
}
284+
281285
fn initialized_args_mut(&mut self) -> &mut Vec<Vec<u8>> {
282286
self.cmd_args.get_or_insert_with(|| vec![b"enclave".to_vec()])
283287
}

intel-sgx/fortanix-sgx-tools/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ edition = "2018"
2020
[dependencies]
2121
# Project dependencies
2222
aesm-client = { version = "0.6.0", path = "../aesm-client", features = ["sgxs"] }
23+
insecure-time = { version = "0.1.0", path = "../insecure-time" }
2324
sgxs-loaders = { version = "0.4.0", path = "../sgxs-loaders" }
2425
enclave-runner = { version = "0.6.0", path = "../enclave-runner" }
2526
sgxs = { version = "0.8.0", path = "../sgxs" }

intel-sgx/fortanix-sgx-tools/src/bin/ftxsgx-runner.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use std::io::{stderr, Write};
1313
use aesm_client::AesmClient;
1414
use enclave_runner::EnclaveBuilder;
1515
use anyhow::Context;
16+
use insecure_time::Rdtscp;
1617
#[cfg(unix)]
1718
use libc::{c_int, c_void, siginfo_t};
1819
#[cfg(unix)]
@@ -77,6 +78,7 @@ fn main() -> Result<(), anyhow::Error> {
7778
.build();
7879

7980
let mut enclave_builder = EnclaveBuilder::new(file.as_ref());
81+
let forced_insecure_time_usercalls = enclave_builder.forced_insecure_time_usercalls();
8082

8183
match args.value_of("signature").map(|v| v.parse().expect("validated")) {
8284
Some(Signature::coresident) => { enclave_builder.coresident_signature().context("While loading coresident signature")?; }
@@ -94,6 +96,12 @@ fn main() -> Result<(), anyhow::Error> {
9496

9597
enclave.run().map_err(|e| {
9698
eprintln!("Error while executing SGX enclave.\n{}", e);
99+
if !forced_insecure_time_usercalls && Rdtscp::is_supported() && e.to_string() == "Enclave panicked: fatal runtime error: assertion failed: usercall_retval.1 == 0\n" {
100+
eprintln!("This might be due to an ABI change related to insecure time in the enclave. If so, this can be resolved by:");
101+
eprintln!(" - recompiling the enclave with a newer toolchain, or");
102+
eprintln!(" - downgrading the enclave runner, or");
103+
eprintln!(" - using a custom enclave runner can calling `EnclaveBuilder::force_insecure_time_usercalls(true)` when building the enclave");
104+
}
97105
std::process::exit(-1)
98106
})
99107
}

0 commit comments

Comments
 (0)