Skip to content

Commit

Permalink
Fix for musl target in pthread_kill
Browse files Browse the repository at this point in the history
  • Loading branch information
Max K committed Jul 5, 2023
1 parent 51ef300 commit a1a2e0f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion intel-sgx/enclave-runner/src/usercalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ impl EnclaveState {

for handler in join_handlers {
#[cfg(unix)]
unsafe { libc::pthread_kill(handler.as_pthread_t(), signal::SIGUSR1 as _); }
unsafe { libc::pthread_kill(handler.as_pthread_t() as _, signal::SIGUSR1 as _); }
let _ = handler.join();
}
return main_result;
Expand Down
5 changes: 2 additions & 3 deletions intel-sgx/fortanix-sgx-tools/src/bin/ftxsgx-runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,14 @@ fn catch_sigusr1() {
let is_enclu = ENCLU.iter().enumerate().all(|(idx, v)| {
unsafe { *instruction_ptr.offset(idx as isize) == *v }
});
let _ = stderr().flush();
if is_enclu {
// At enclu instruction - force IP to the next instruction after enclu
unsafe { (*(_context as *mut ucontext_t)).uc_mcontext.gregs[REG_RIP as usize] += 3 }
eprintln!("Enclave thread {:?} hanged and aboarted by the signal", std::thread::current().id());
}
let _ = stderr().flush();
}

// POC: Need to think about what signal to send & hook

let hdl = signal::SigHandler::SigAction(handle_sigusr1);
let sig_action = signal::SigAction::new(hdl, signal::SaFlags::empty(), signal::SigSet::empty());
signal::sigaction(signal::SIGUSR1, &sig_action).unwrap();
Expand Down

0 comments on commit a1a2e0f

Please sign in to comment.