Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI #561

Merged
merged 4 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions intel-sgx/aesm-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#![doc(html_logo_url = "https://edp.fortanix.com/img/docs/edp-logo.svg",
html_favicon_url = "https://edp.fortanix.com/favicon.ico",
html_root_url = "https://edp.fortanix.com/docs/api/")]
#![allow(non_local_definitions)] // Required by failure
#![deny(warnings)]

extern crate byteorder;
Expand Down Expand Up @@ -284,6 +285,7 @@ impl EinittokenProvider for AesmClient {
trait AesmRequest: protobuf::Message + Into<Request> {
type Response: protobuf::Message + FromResponse;

#[cfg(not(target_env = "sgx"))]
fn get_timeout(&self) -> Option<u32>;
}

Expand All @@ -297,6 +299,7 @@ macro_rules! define_aesm_message {
impl AesmRequest for $request {
type Response = $response;

#[cfg(not(target_env = "sgx"))]
fn get_timeout(&self) -> Option<u32> {
if self.has_timeout() {
Some(Self::get_timeout(self))
Expand Down
4 changes: 2 additions & 2 deletions intel-sgx/async-usercalls/src/io_bufs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ impl ReadBuffer {

#[cfg(test)]
mod tests {
use super::*;
use super::{ReadBuffer, UserBuf, WriteBuffer};
use std::os::fortanix_sgx::usercalls::alloc::User;

#[test]
Expand Down Expand Up @@ -330,4 +330,4 @@ mod tests {
assert_eq!(read_buffer.remaining_bytes(), 0);
assert_eq!(&buf, b"hello\0\0\0");
}
}
}
2 changes: 1 addition & 1 deletion intel-sgx/async-usercalls/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl CallbackHandler {

#[cfg(test)]
mod tests {
use super::*;
use super::{AsyncUsercallProvider, UserBuf};
use crate::test_support::*;
use crate::utils::MakeSend;
use crossbeam_channel as mpmc;
Expand Down
2 changes: 1 addition & 1 deletion intel-sgx/async-usercalls/src/queues.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::provider_core::ProviderId;
use crossbeam_channel as mpmc;
use fortanix_sgx_abi::{EV_CANCELQ_NOT_FULL, EV_RETURNQ_NOT_EMPTY, EV_USERCALLQ_NOT_FULL};
use ipc_queue::{self, Identified, QueueEvent, RecvError, SynchronizationError, Synchronizer};
use ipc_queue::{Identified, QueueEvent, RecvError, SynchronizationError, Synchronizer};
use lazy_static::lazy_static;
use std::os::fortanix_sgx::usercalls::alloc::User;
use std::os::fortanix_sgx::usercalls::raw::{
Expand Down
4 changes: 2 additions & 2 deletions intel-sgx/async-usercalls/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl RawApi for AsyncUsercallProvider {

#[cfg(test)]
mod tests {
use super::*;
use super::RawApi;
use crate::test_support::*;
use crossbeam_channel as mpmc;
use std::io;
Expand Down Expand Up @@ -240,4 +240,4 @@ mod tests {
}
rx.recv().unwrap();
}
}
}
1 change: 1 addition & 0 deletions intel-sgx/enclave-runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#![allow(non_local_definitions)] // Required by failure
#![deny(warnings)]
#![doc(
html_logo_url = "https://edp.fortanix.com/img/docs/edp-logo.svg",
Expand Down
1 change: 0 additions & 1 deletion intel-sgx/enclave-runner/src/tcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use std;
use std::arch::asm;
use std::cell::RefCell;
use std::convert::{TryFrom, TryInto};
Expand Down
17 changes: 2 additions & 15 deletions intel-sgx/enclave-runner/src/usercalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::thread::{self, JoinHandle};
use std::time::{self, Duration};
use std::{cmp, fmt, str};

use failure::{self, bail};
use failure::bail;
use fnv::FnvHashMap;
use futures::future::{poll_fn, Either, Future, FutureExt};
use futures::lock::Mutex;
Expand All @@ -31,7 +31,7 @@ use tokio::io::{AsyncRead, AsyncWrite};
use tokio::stream::Stream as TokioStream;
use tokio::sync::{broadcast, mpsc as async_mpsc, oneshot, Semaphore};
use fortanix_sgx_abi::*;
use ipc_queue::{self, DescriptorGuard, Identified, QueueEvent};
use ipc_queue::{DescriptorGuard, Identified, QueueEvent};
use ipc_queue::position::WritePosition;
use sgxs::loader::Tcs as SgxsTcs;

Expand Down Expand Up @@ -120,19 +120,6 @@ impl AsyncRead for Stdin {
fn poll_read(self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8]) -> Poll<tokio::io::Result<usize>> {
const BUF_SIZE: usize = 8192;

trait AsIoResult<T> {
fn as_io_result(self) -> io::Result<T>;
}

impl<T> AsIoResult<T> for Poll<T> {
fn as_io_result(self) -> io::Result<T> {
match self {
Poll::Ready(v) => Ok(v),
Poll::Pending => Err(io::ErrorKind::WouldBlock.into()),
}
}
}

struct AsyncStdin {
rx: async_mpsc::Receiver<VecDeque<u8>>,
buf: VecDeque<u8>,
Expand Down
4 changes: 2 additions & 2 deletions intel-sgx/sgxs/src/sgxs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ impl<W: Write> SgxsWrite for W {
let mut buf = [0u8; 64];
unsafe {
let (tag, headerdst) = buf.split_at_mut(8);
let tag = &mut *(&mut tag[0] as *mut _ as *mut u64);
let headerdst = &mut headerdst[0] as *mut _;
let tag = &mut *(&mut tag[0..8] as *mut _ as *mut u64);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, so new nightly compiler will warn this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it surprised me too!

let headerdst = &mut headerdst[0..56] as *mut _;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raoulstrackx Where is this 56 byte size mentioned? I understand in the line above that 8 bytes translate to u64, but what is this type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's size comes from how MRENCLAVE is being measured. See the sgxs documentation and Intel Manual vol 3D ch 36.4.1.1 At the Rust code level, there isn't one an explicit type for it. Based on what's being added (ECreate, Unsized,...) different types are used.


match meas {
&ECreate(ref header) => {
Expand Down
2 changes: 1 addition & 1 deletion intel-sgx/sgxs/src/sigstruct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use failure::Error;
use time::OffsetDateTime;
use time::macros::format_description;

use abi::{self, SIGSTRUCT_HEADER1, SIGSTRUCT_HEADER2};
use abi::{SIGSTRUCT_HEADER1, SIGSTRUCT_HEADER2};
pub use abi::{Attributes, AttributesFlags, Miscselect, Sigstruct};
use crypto::{Hash, SgxHashOps, SgxRsaOps, SgxRsaPubOps};
use sgxs::{copy_measured, SgxsRead};
Expand Down
7 changes: 6 additions & 1 deletion ipc-queue/src/fifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ use std::sync::atomic::{AtomicUsize, Ordering, Ordering::SeqCst};

use fortanix_sgx_abi::{FifoDescriptor, WithId};

use super::*;
#[cfg(target_env = "sgx")]
use super::{Identified, Transmittable, TryRecvError, TrySendError, UserRef, UserSafeSized};

#[cfg(not(target_env = "sgx"))]
use super::{AsyncReceiver, AsyncSender, AsyncSynchronizer, DescriptorGuard, Identified, Receiver, Sender,
Synchronizer, Transmittable, TryRecvError, TrySendError};

// `fortanix_sgx_abi::WithId` is not `Copy` because it contains an `AtomicU64`.
// This type has the same memory layout but is `Copy` and can be marked as
Expand Down
2 changes: 1 addition & 1 deletion ipc-queue/src/interface_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use fortanix_sgx_abi::FifoDescriptor;

use super::*;
use super::{Fifo, Identified, QueueEvent, Receiver, RecvError, Sender, SendError, SynchronizationError, Synchronizer, Transmittable, TryRecvError, TrySendError};

unsafe impl<T: Send, S: Send> Send for Sender<T, S> {}
unsafe impl<T: Send, S: Sync> Sync for Sender<T, S> {}
Expand Down