diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 696b0c9ea..3b51ed9df 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -135,3 +135,23 @@ jobs: - name: snmalloc correctness test run: cd ./examples/mem-correctness-test && cargo run + + - name: Cargo test -p enclave-runner-client --no-default-features --features alloc + run: cargo test --verbose --locked -p enclave-runner-client --no-default-features --features alloc + + - name: Load vsock_loopback kernel module (non-blocking) + id: vsock + run: | + if sudo modprobe vsock_loopback; then + echo "loaded=true" >> "$GITHUB_OUTPUT" + else + echo "::warning title=vsock_loopback unavailable::Could not load vsock_loopback, skipping the enclave-runner-client loopback tests." + fi + + - name: Cargo test -p enclave-runner-client --test loopback (vsock loopback) + if: steps.vsock.outputs.loaded == 'true' + run: cargo test --verbose --locked -p enclave-runner-client --test loopback -- --ignored + + - name: Cargo test -p enclave-runner-client --no-default-features --features alloc --test loopback (vsock loopback) + if: steps.vsock.outputs.loaded == 'true' + run: cargo test --verbose --locked -p enclave-runner-client --no-default-features --features alloc --test loopback -- --ignored \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 9fb525cfe..a5db5119c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1037,6 +1037,12 @@ dependencies = [ "libc", ] +[[package]] +name = "compiler_builtins" +version = "0.1.160" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6376049cfa92c0aa8b9ac95fae22184b981c658208d4ed8a1dc553cd83612895" + [[package]] name = "confidential-vm-blobs" version = "0.2.0" @@ -1472,7 +1478,7 @@ dependencies = [ "aws-nitro-enclaves-image-format", "libc", "nix 0.26.4", - "vsock", + "vsock 0.5.2", ] [[package]] @@ -1600,6 +1606,18 @@ dependencies = [ "tokio", ] +[[package]] +name = "enclave-runner-client" +version = "0.1.0" +dependencies = [ + "fortanix-vme-abi", + "libc", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", + "serde_cbor", + "vsock 0.2.4", +] + [[package]] name = "enclave-runner-sgx" version = "0.1.4" @@ -1679,7 +1697,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1868,7 +1886,7 @@ dependencies = [ "thiserror 2.0.18", "tokio", "tokio-vsock", - "vsock", + "vsock 0.5.2", ] [[package]] @@ -2027,8 +2045,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" dependencies = [ "cfg-if 1.0.0", + "compiler_builtins", "js-sys", "libc", + "rustc-std-workspace-core", "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", ] @@ -2674,7 +2694,7 @@ checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" dependencies = [ "hermit-abi 0.5.2", "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -2832,9 +2852,12 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.186" +version = "0.2.191" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" +dependencies = [ + "rustc-std-workspace-core", +] [[package]] name = "libloading" @@ -3143,7 +3166,7 @@ dependencies = [ "sha2 0.9.9", "signal-hook", "vmm-sys-util", - "vsock", + "vsock 0.5.2", ] [[package]] @@ -3185,6 +3208,19 @@ dependencies = [ "memoffset 0.6.4", ] +[[package]] +name = "nix" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf" +dependencies = [ + "bitflags 1.2.1", + "cc", + "cfg-if 1.0.0", + "libc", + "memoffset 0.6.4", +] + [[package]] name = "nix" version = "0.26.4" @@ -3837,7 +3873,7 @@ dependencies = [ "once_cell", "socket2 0.6.5", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -4198,15 +4234,15 @@ source = "git+https://github.com/fortanix/rustc-serialize.git?branch=portability [[package]] name = "rustc-std-workspace-alloc" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff66d57013a5686e1917ed6a025d54dd591fcda71a41fe07edf4d16726aefa86" +checksum = "f9d441c3b2ebf55cebf796bfdc265d67fa09db17b7bb6bd4be75c509e1e8fec3" [[package]] name = "rustc-std-workspace-core" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1956f5517128a2b6f23ab2dadf1a976f4f5b27962e7724c2bf3d45e539ec098c" +checksum = "aa9c45b374136f52f2d6311062c7146bff20fec063c3f5d46a410bd937746955" [[package]] name = "rustc_version" @@ -4227,7 +4263,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.4.15", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4240,7 +4276,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.12.1", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -4972,7 +5008,7 @@ dependencies = [ "getrandom 0.4.3", "once_cell", "rustix 1.1.4", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -5245,7 +5281,7 @@ dependencies = [ "futures 0.3.31", "libc", "tokio", - "vsock", + "vsock 0.5.2", ] [[package]] @@ -5580,6 +5616,18 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" +[[package]] +name = "vsock" +version = "0.2.4" +source = "git+https://github.com/fortanix/vsock-rs.git?branch=gianlu33%2Frte-1352-tmp#163c3de32e9cce6e02026c9768caab03acd9c469" +dependencies = [ + "compiler_builtins", + "getrandom 0.2.17", + "libc", + "nix 0.22.3", + "rustc-std-workspace-core", +] + [[package]] name = "vsock" version = "0.5.2" @@ -5617,6 +5665,11 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", +] [[package]] name = "wasm-bindgen" diff --git a/Cargo.toml b/Cargo.toml index b0244db1e..cd115d452 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ members = [ "fortanix-vme/aws-nitro-enclaves/nitro-attestation-verify", "fortanix-vme/aws-nitro-enclaves/nsm", "fortanix-vme/aws-nitro-enclaves/tests/nsm-test", + "fortanix-vme/enclave-runner-client", "fortanix-vme/fortanix-vme-abi", "fortanix-vme/fortanix-vme-eif", "fortanix-vme/fortanix-vme-initramfs", diff --git a/fortanix-vme/enclave-runner-client/Cargo.toml b/fortanix-vme/enclave-runner-client/Cargo.toml new file mode 100644 index 000000000..22eb6e9be --- /dev/null +++ b/fortanix-vme/enclave-runner-client/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "enclave-runner-client" +version = "0.1.0" +edition = "2024" +authors = ["Fortanix, Inc."] + +[dependencies] +core = { version = "1.0.1", optional = true, package = "rustc-std-workspace-core" } +alloc = { version = "1.0.1", optional = true, package = "rustc-std-workspace-alloc" } + +vsock = { git = "https://github.com/fortanix/vsock-rs.git", branch = "gianlu33/rte-1352-tmp", default-features = false, features = ["random_port"] } +serde_cbor = { version = "0.11", default-features = false, features = ["alloc"] } + +# `fortanix/rust` patches libc to our `fortanix/libc` fork (branch `fortanixvme-2023-05-07-alpha), +# which is currently at version 0.2.175. Specifying a higher version here will make cargo use upstream +# libc, which will break std compilation as upstream libc is not aware of the fortanixvme target. +libc = { version = "0.2.175", default-features = false } + +fortanix-vme-abi = { path = "../fortanix-vme-abi", default-features = false, features = ["serde"] } + +[dev-dependencies] + +[features] +std = ["vsock/std", "serde_cbor/std", "libc/std", "fortanix-vme-abi/std"] +default = ["std"] +rustc-dep-of-std = [ + "core", + "alloc", + "vsock/rustc-dep-of-std", + "libc/rustc-dep-of-std", + "fortanix-vme-abi/rustc-dep-of-std", +] diff --git a/fortanix-vme/enclave-runner-client/src/client.rs b/fortanix-vme/enclave-runner-client/src/client.rs new file mode 100644 index 000000000..080cd9885 --- /dev/null +++ b/fortanix-vme/enclave-runner-client/src/client.rs @@ -0,0 +1,233 @@ +// std types are just re-exports of alloc/core types. Conditional compilation is not necessary here, +// and it allows clean compilation even with no features enabled. +use { + alloc::string::String, + alloc::vec::Vec, +}; +use fortanix_vme_abi::{self, ErrorKind, Request, Response, Addr}; +use vsock::{VsockStream, VsockListener}; + +use crate::Error; +use crate::connection_info::ConnectionInfo; +use crate::platform::ClientPlatform; + +/// A raw file descriptor. Same type as `std::os::fd::RawFd`. +pub type RawFd = libc::c_int; + +/// The byte stream to the runner. Implemented for the vsock stream; tests +/// implement it for an in-memory fake. +pub(crate) trait Transport { + fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>; + fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>; +} + +impl Transport for VsockStream { + fn write_all(&mut self, buf: &[u8]) -> Result<(), Error> { + VsockStream::write_all(&*self, buf).map(|_| ()).map_err(Error::from) + } + fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error> { + VsockStream::read_exact(&*self, buf).map_err(Error::from) + } +} + +/// A handle to the enclave runner. +/// +/// Each method sends one request to the runner's command server and waits for +/// its reply. A `Client` holds no connection between calls, so creating one +/// does not contact the runner, and errors from reaching the runner are +/// returned by the method calls. +/// +/// [`Client::default()`] talks to the runner on its standard port, +/// [`fortanix_vme_abi::SERVER_PORT`]. Use [`Client::new`] for another port. +#[derive(Clone, Debug)] +pub struct Client { + port: u32, +} + +impl Default for Client { + /// A client for the runner's standard command port, + /// [`fortanix_vme_abi::SERVER_PORT`]. + fn default() -> Self { + Client::new(fortanix_vme_abi::SERVER_PORT) + } +} + +impl Client { + /// Client for a runner listening on vsock `port`. + pub fn new(port: u32) -> Self { + Client { port } + } + + /// Connects the runner to `addr` (`"host:port"`) and returns a vsock stream + /// that the runner forwards to it. + /// + /// The caller owns the returned fd. Call + /// [`close_connection`](Self::close_connection) before closing it. + pub fn open_proxy_connection(&self, addr: impl Into) -> Result<(RawFd, ConnectionInfo), Error> { + let reply = Connection::open(self.port)?.request(&Request::Connect { addr: addr.into() })?; + let Response::Connected { proxy_port, local, peer } = reply else { + return Err(Error::IoError(ErrorKind::InvalidData)); + }; + + let proxy = connect(proxy_port)?; + let enclave_port = proxy.local_addr()?.port(); + Ok(( + proxy.into_raw_fd(), + ConnectionInfo::new_stream_info(enclave_port, local, peer) + )) + } + + /// Bind a TCP socket in the runner to the specified address. Returns a vsock + /// listener for the connections forwarded by the runner. + /// + /// Use [`accept`](Self::accept) to wait for a connection. The caller owns + /// the returned fd. Call [`close_connection`](Self::close_connection) before + /// closing it. + pub fn bind_socket(&self, addr: impl Into) -> Result<(RawFd, ConnectionInfo), Error> { + // Start listener socket within enclave, waiting for incoming connections from enclave + // runner + let listener = VsockListener::::bind_with_cid(vsock::VMADDR_CID_ANY)?; + let enclave_port = listener.local_addr()?.port(); + + // Tell runner to start listening on the specified address and forward traffic to the + // specified port + let bind = Request::Bind { addr: addr.into(), enclave_port }; + let Response::Bound { local } = Connection::open(self.port)?.request(&bind)? else { + return Err(Error::IoError(ErrorKind::InvalidData)); + }; + Ok(( + listener.into_raw_fd(), + ConnectionInfo::new_listener_info(local, enclave_port) + )) + } + + /// Waits for a TCP connection on the listener at `enclave_port` (see + /// [`bind_socket`](Self::bind_socket)). + /// + /// Returns the local and peer TCP addresses, and the runner's vsock port. + /// After replying, the runner connects to the listener from that port, so + /// accept the connection on the listener fd. + pub fn accept(&self, enclave_port: u32) -> Result<(Addr, Addr, u32), Error> { + let accept = Request::Accept { enclave_port }; + match Connection::open(self.port)?.request(&accept)? { + Response::IncomingConnection { local, peer, proxy_port } => Ok((local, peer, proxy_port)), + _ => Err(Error::IoError(ErrorKind::InvalidData)), + } + } + + /// Tells the runner to close the listener or connection on `enclave_port`. + /// + /// This doesn't close the enclave's fd. Close it afterwards, so the port + /// isn't reused while the runner still has it. + pub fn close_connection(&self, enclave_port: u32) -> Result<(), Error> { + match Connection::open(self.port)?.request(&Request::Close { enclave_port })? { + Response::Closed => Ok(()), + _ => Err(Error::IoError(ErrorKind::InvalidData)), + } + } + + /// Returns the enclave's command-line arguments. + pub fn args(&self) -> Result, Error> { + match Connection::open(self.port)?.request(&Request::Init)? { + Response::Init { args } => Ok(args), + _ => Err(Error::IoError(ErrorKind::InvalidData)), + } + } + + /// Asks the runner to exit with `code`, then exits the enclave, even if the + /// runner can't be reached. + pub fn exit(&self, code: i32) -> ! { + let _ = Connection::open(self.port) + .and_then(|conn| conn.send(&Request::Exit { code })); + + // Failed to connect to the runner, stop the enclave anyway + // SAFETY: `exit` has no preconditions. + unsafe { libc::exit(code as libc::c_int) } + } +} + +/// A connection to the runner's command server. The runner handles one request +/// per connection, so `request` and `send` consume it. +struct Connection { + stream: VsockStream, +} + +impl Connection { + fn open(port: u32) -> Result { + Ok(Connection { stream: connect(port)? }) + } + + /// Sends `req` and waits for the reply. + fn request(mut self, req: &Request) -> Result { + send_request(&mut self.stream, req)?; + receive_response(&mut self.stream) + } + + /// Sends `req` without waiting for a reply (the runner doesn't answer `Exit`). + fn send(mut self, req: &Request) -> Result<(), Error> { + send_request(&mut self.stream, req) + } +} + +/// Establishes a VSock connection to the enclave runner on the given port. +/// +/// Tries the conventional host CID first, followed by the local CID +/// for local execution and debugging. Falls back to the AWS Nitro +/// parent CID to support Nitro Enclaves. +/// +/// The connection order preserves compatibility with existing +/// non-Nitro environments. +/// +fn connect(port: u32) -> Result, Error> { + const AWS_NITRO_PARENT_CID: u32 = 3; + + let host_error = match VsockStream::connect_with_cid_port( + vsock::VMADDR_CID_HOST, + port, + ) { + Ok(stream) => return Ok(stream), + Err(err) => err, + }; + + for cid in [vsock::VMADDR_CID_LOCAL, AWS_NITRO_PARENT_CID] { + if let Ok(stream) = VsockStream::connect_with_cid_port(cid, port) { + return Ok(stream); + } + } + + Err(host_error.into()) +} + +/// Writes `req` as one frame: the body length as a little-endian `usize`, then +/// the CBOR body. Same framing as the runner's `ClientConnection`. +pub(crate) fn send_request(stream: &mut S, req: &Request) -> Result<(), Error> { + let req: Vec = serde_cbor::ser::to_vec(req) + .map_err(|_e| Error::SerializationError)?; + stream.write_all(&req.len().to_le_bytes())?; + stream.write_all(req.as_slice())?; + Ok(()) +} + +/// Reads one frame and decodes it. A `Response::Failed` becomes an `Err`. +pub(crate) fn receive_response(stream: &mut S) -> Result { + let mut size = [0u8; usize::BITS as usize / 8]; + stream.read_exact(&mut size[..])?; + let size = usize::from_le_bytes(size); + + let mut resp = Vec::new(); + resp.resize(size, 0); + stream.read_exact(&mut resp[..])?; + let resp = serde_cbor::from_slice(&resp) + .map_err(|_| Error::DeserializationError)?; + + match resp { + fortanix_vme_abi::Response::Failed(fortanix_vme_abi::Error::Command(kind)) => { + Err(Error::IoError(kind)) + } + fortanix_vme_abi::Response::Failed(fortanix_vme_abi::Error::SystemError(errno)) => { + Err(Error::SystemError(errno)) + } + fortanix_vme_abi::Response::Failed(e) => Err(Error::Other(alloc::format!("{:?}", e))), + other => Ok(other), + } +} diff --git a/fortanix-vme/enclave-runner-client/src/connection_info.rs b/fortanix-vme/enclave-runner-client/src/connection_info.rs new file mode 100644 index 000000000..6677bb423 --- /dev/null +++ b/fortanix-vme/enclave-runner-client/src/connection_info.rs @@ -0,0 +1,57 @@ +use fortanix_vme_abi::{Addr}; + +/// What the enclave knows about a TCP socket that the runner holds for it. +/// +/// Returned by [`Client::open_proxy_connection`](crate::Client::open_proxy_connection) +/// and [`Client::bind_socket`](crate::Client::bind_socket). +#[derive(Clone, Debug)] +pub enum ConnectionInfo { + /// A TCP listener in the runner, which forwards incoming connections to a + /// vsock listener in the enclave. + Listener { + /// The vsock port the enclave is listening on to receive connections from the runner + enclave_port: u32, + /// The local address (of the runner) the socket is bound to + local: Addr, + }, + /// A TCP connection in the runner, forwarded over a vsock stream to the + /// enclave. + Stream { + /// The vsock port the enclave is using to communicate with the runner + enclave_port: u32, + /// The local address the socket is bound to. + local: Addr, + /// The peer the socket is connected to. + peer: Addr, + }, +} + +impl ConnectionInfo { + /// Creates a [`ConnectionInfo::Stream`]. + pub fn new_stream_info( + enclave_port: u32, + local: Addr, + peer: Addr, + ) -> Self { + ConnectionInfo::Stream { enclave_port, local, peer } + } + + /// Creates a [`ConnectionInfo::Listener`]. + pub fn new_listener_info( + local: Addr, + enclave_port: u32, + ) -> Self { + ConnectionInfo::Listener { enclave_port, local } + } + + /// Returns the enclave's vsock port for this listener or stream. The + /// runner uses this port to identify it, for example in + /// [`Client::accept`](crate::Client::accept) and + /// [`Client::close_connection`](crate::Client::close_connection). + pub fn enclave_port(&self) -> u32 { + match self { + ConnectionInfo::Listener { enclave_port, .. } => *enclave_port, + ConnectionInfo::Stream { enclave_port, .. } => *enclave_port, + } + } +} diff --git a/fortanix-vme/enclave-runner-client/src/lib.rs b/fortanix-vme/enclave-runner-client/src/lib.rs new file mode 100644 index 000000000..05ccbc89b --- /dev/null +++ b/fortanix-vme/enclave-runner-client/src/lib.rs @@ -0,0 +1,108 @@ +//! Client for the Fortanix VME enclave runner's command protocol. +//! +//! Code inside a fortanixvme enclave has no network stack of its own. It asks +//! the enclave runner on the parent VM to open TCP connections, listen on ports +//! and pass in the enclave's arguments. Requests go over vsock to the runner at +//! [`fortanix_vme_abi::SERVER_PORT`] by default. Each one is a CBOR-encoded +//! [`fortanix_vme_abi::Request`] sent as one length-prefixed frame. +//! +//! The client tries `VMADDR_CID_HOST` first and falls back to `VMADDR_CID_LOCAL`, +//! so it also works with a runner on the same host (for debugging and simulation). +//! As last resort, it also tries `AWS_NITRO_PARENT_CID` (CID 3), specific to Nitro. +//! +//! The runner handles **one request per connection**: a [`Client`] creates a new +//! connection for each request, so the same client can be reused. +//! +//! # Features +//! - `std` (default): uses `std` to read `errno`. +//! - `alloc`: `no_std` build that reads `errno` through `libc`. +//! - `rustc-dep-of-std`: for building as a dependency of the `fortanix/rust` std. + +#![no_std] +#![warn(missing_docs)] + +#[cfg(feature="std")] +extern crate std; +#[cfg_attr(feature = "rustc-dep-of-std", allow(unused_extern_crates))] +extern crate alloc; + +use core::fmt::{Display, Error as FmtError, Formatter}; +use alloc::string::{String, ToString}; + +mod platform; + +mod connection_info; +pub use connection_info::*; + +mod client; +pub use client::*; + +pub use fortanix_vme_abi::{Addr, ErrorKind as IoError}; + +/// Errors returned by this crate. +#[derive(Debug, PartialEq, Eq)] +pub enum Error { + /// An argument is not valid, for example a reserved vsock port or a wrong + /// address type. + InvalidInput, + /// A system call failed with this `errno`. The call is either a local + /// socket call or one made by the runner, which sends its `errno` back. + SystemError(i32), + /// An I/O error. Either the runner failed the command with this kind (for + /// example [`IoError::ConnectionRefused`] when the remote server refuses + /// the connection), the runner sent a reply of the wrong type + /// ([`IoError::InvalidData`]), or the vsock connection closed or stopped + /// accepting data ([`IoError::UnexpectedEof`], [`IoError::WriteZero`]). + IoError(IoError), + /// The request could not be encoded as CBOR. + SerializationError, + /// The runner's reply could not be decoded as a + /// [`Response`](fortanix_vme_abi::Response). + DeserializationError, + /// Any other error, with a description. Used for runner errors that have no + /// variant of their own (such as `ConnectionNotFound`), formatted with + /// `Debug`, and for vsock failing to get random bytes for a port number. + Other(String), +} + +impl Display for Error { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { + match self { + Error::InvalidInput => write!(f, "invalid input"), + Error::SystemError(errno) => write!(f, "system error {}", errno), + Error::IoError(error) => write!(f, "I/O error: {:?}", error), + Error::SerializationError => write!(f, "serialization error"), + Error::DeserializationError => write!(f, "deserialization error"), + Error::Other(reason) => write!(f, "{}", reason), + } + } +} + +impl From for Error { + fn from(err: vsock::Error) -> Error { + match err { + vsock::Error::EntropyError => { + Error::Other("EntropyError".to_string()) + } + vsock::Error::ReservedPort => { + Error::InvalidInput + } + vsock::Error::SystemError(errno) => Error::SystemError(errno), + vsock::Error::WrongAddressType => { + Error::InvalidInput + } + vsock::Error::ZeroDurationTimeout => { + Error::InvalidInput + } + vsock::Error::WriteAllEof => { + Error::IoError(IoError::WriteZero) + } + vsock::Error::UnexpectedEof => { + Error::IoError(IoError::UnexpectedEof) + } + } + } +} + +#[cfg(test)] +mod test; diff --git a/fortanix-vme/enclave-runner-client/src/platform.rs b/fortanix-vme/enclave-runner-client/src/platform.rs new file mode 100644 index 000000000..76cb327e8 --- /dev/null +++ b/fortanix-vme/enclave-runner-client/src/platform.rs @@ -0,0 +1,23 @@ +use vsock::{self, Platform}; + +/// [`vsock::Platform`] for this crate: tells `vsock` how to read `errno` +/// after a failed socket call. +/// +/// Uses `std::io::Error::last_os_error` with the `std` feature, and libc's +/// `__errno_location` without it (e.g. when built as part of std via +/// `rustc-dep-of-std`). +/// +/// Returns `SystemError(0)` if the OS reports no error code, where +/// `vsock::Std` would panic. +pub(crate) struct ClientPlatform; + +impl Platform for ClientPlatform { + fn last_os_error() -> vsock::Error { + #[cfg(feature = "std")] + let errno = std::io::Error::last_os_error().raw_os_error().unwrap_or(0); + #[cfg(not(feature = "std"))] + // SAFETY: `__errno_location` returns a valid pointer to this thread's errno. + let errno = unsafe { *libc::__errno_location() }; + vsock::Error::SystemError(errno as i32) + } +} diff --git a/fortanix-vme/enclave-runner-client/src/test.rs b/fortanix-vme/enclave-runner-client/src/test.rs new file mode 100644 index 000000000..c9457ede0 --- /dev/null +++ b/fortanix-vme/enclave-runner-client/src/test.rs @@ -0,0 +1,173 @@ +//! Framing and error mapping, tested with an in-memory stand-in for +//! the vsock stream. No sockets needed. + +mod tests { + use alloc::string::ToString; + use alloc::vec::Vec; + + use fortanix_vme_abi::{Addr, Error as RunnerError, ErrorKind, Request, Response}; + + use crate::client::{receive_response, send_request, Transport}; + use crate::{ConnectionInfo, Error}; + + /// In-memory stand-in for the vsock stream: records what the client writes + /// and serves `input` as the runner's replies. + #[derive(Default)] + struct Mock { + written: Vec, + input: Vec, + pos: usize, + } + + impl Mock { + fn replying(input: Vec) -> Self { + Mock { input, ..Default::default() } + } + } + + impl Transport for Mock { + fn write_all(&mut self, buf: &[u8]) -> Result<(), Error> { + self.written.extend_from_slice(buf); + Ok(()) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error> { + let end = self.pos + buf.len(); + // Same error the real stream gives when the runner hangs up. + let src = self + .input + .get(self.pos..end) + .ok_or(Error::IoError(ErrorKind::UnexpectedEof))?; + buf.copy_from_slice(src); + self.pos = end; + Ok(()) + } + } + + /// Frames a message the way the runner does (`ClientConnection::send` in + /// fortanix-vme-runner): body length as a little-endian `usize`, then the body. + fn frame(body: &[u8]) -> Vec { + let mut frame = body.len().to_le_bytes().to_vec(); + frame.extend_from_slice(body); + frame + } + + fn runner_reply(resp: &Response) -> Vec { + frame(&serde_cbor::ser::to_vec(resp).unwrap()) + } + + fn receive(input: Vec) -> Result { + receive_response(&mut Mock::replying(input)) + } + + // send_request + + #[test] + fn send_writes_length_then_cbor() { + let req = Request::Bind { addr: "0.0.0.0:8080".to_string(), enclave_port: 1234 }; + let mut mock = Mock::default(); + + send_request(&mut mock, &req).unwrap(); + + assert_eq!(mock.written, frame(&serde_cbor::ser::to_vec(&req).unwrap())); + } + + // receive_response: replies + + #[test] + fn receive_returns_reply() { + let reply = Response::Init { args: ["enclave", "--flag"].map(ToString::to_string).to_vec() }; + assert_eq!(receive(runner_reply(&reply)), Ok(reply)); + } + + #[test] + fn receive_reads_exactly_one_frame() { + let mut input = runner_reply(&Response::Closed); + input.extend(runner_reply(&Response::Bound { local: localhost(80) })); + let mut mock = Mock::replying(input); + + assert_eq!(receive_response(&mut mock), Ok(Response::Closed)); + assert_eq!(receive_response(&mut mock), Ok(Response::Bound { local: localhost(80) })); + } + + // receive_response: runner errors + + #[test] + fn command_error_becomes_io_error() { + let reply = Response::Failed(RunnerError::Command(ErrorKind::ConnectionRefused)); + assert_eq!(receive(runner_reply(&reply)), Err(Error::IoError(ErrorKind::ConnectionRefused))); + } + + #[test] + fn system_error_becomes_system_error() { + let reply = Response::Failed(RunnerError::SystemError(104)); + assert_eq!(receive(runner_reply(&reply)), Err(Error::SystemError(104))); + } + + #[test] + fn other_runner_errors_are_not_lost() { + for err in [RunnerError::ConnectionNotFound, RunnerError::Unknown, RunnerError::VsockError] { + let result = receive(runner_reply(&Response::Failed(err))); + assert!(matches!(result, Err(Error::Other(_))), "got {:?}", result); + } + } + + // receive_response: broken frames + + #[test] + fn empty_or_short_length_is_unexpected_eof() { + assert_eq!(receive(Vec::new()), Err(Error::IoError(ErrorKind::UnexpectedEof))); + assert_eq!(receive([1, 0, 0].to_vec()), Err(Error::IoError(ErrorKind::UnexpectedEof))); + } + + #[test] + fn truncated_body_is_unexpected_eof() { + let mut input = runner_reply(&Response::Closed); + input.pop(); + assert_eq!(receive(input), Err(Error::IoError(ErrorKind::UnexpectedEof))); + } + + #[test] + fn garbage_body_is_deserialization_error() { + assert_eq!(receive(frame(&[0xff, 0xff, 0xff])), Err(Error::DeserializationError)); + } + + // Error conversions and helpers + + #[test] + fn vsock_errors_map_to_client_errors() { + let cases = [ + (vsock::Error::EntropyError, Error::Other("EntropyError".to_string())), + (vsock::Error::ReservedPort, Error::InvalidInput), + (vsock::Error::SystemError(13), Error::SystemError(13)), + (vsock::Error::WrongAddressType, Error::InvalidInput), + (vsock::Error::ZeroDurationTimeout, Error::InvalidInput), + (vsock::Error::WriteAllEof, Error::IoError(ErrorKind::WriteZero)), + (vsock::Error::UnexpectedEof, Error::IoError(ErrorKind::UnexpectedEof)), + ]; + for (from, expected) in cases { + assert_eq!(Error::from(from), expected); + } + } + + #[test] + fn error_display() { + assert_eq!(Error::InvalidInput.to_string(), "invalid input"); + assert_eq!(Error::SystemError(104).to_string(), "system error 104"); + assert_eq!(Error::IoError(ErrorKind::NotFound).to_string(), "I/O error: NotFound"); + assert_eq!(Error::Other("boom".to_string()).to_string(), "boom"); + } + + #[test] + fn connection_info_accessors() { + let stream = ConnectionInfo::new_stream_info(5, localhost(1), localhost(2)); + assert_eq!(stream.enclave_port(), 5); + + let listener = ConnectionInfo::new_listener_info(localhost(3), 6); + assert_eq!(listener.enclave_port(), 6); + } + + fn localhost(port: u16) -> Addr { + Addr::IPv4 { ip: [127, 0, 0, 1], port } + } +} diff --git a/fortanix-vme/enclave-runner-client/tests/loopback.rs b/fortanix-vme/enclave-runner-client/tests/loopback.rs new file mode 100644 index 000000000..111cde738 --- /dev/null +++ b/fortanix-vme/enclave-runner-client/tests/loopback.rs @@ -0,0 +1,275 @@ +//! `Client` against a fake runner over vsock loopback (CID 1). +//! +//! Needs the `vsock_loopback` kernel module, so every test is ignored by default. +//! Run them in both builds of the client: +//! +//! sudo modprobe vsock_loopback +//! cargo test -p enclave-runner-client --test loopback -- --ignored +//! cargo test -p enclave-runner-client --no-default-features --features alloc --test loopback -- --ignored +//! +//! The fake runner only uses vsock APIs that exist without vsock's `std` feature, +//! so this file compiles in both builds. Each fake runner listens on a random +//! port, so the tests can run in parallel. `Client::exit` is not tested here: it +//! calls `libc::exit`, which would end the test process. + +use std::thread::{self, JoinHandle}; +use std::time::Duration; + +use enclave_runner_client::{Client, ConnectionInfo, Error}; +use fortanix_vme_abi::{Addr, Error as RunnerError, ErrorKind, Request, Response}; +use vsock::{Platform, VsockListener, VsockStream, VMADDR_CID_LOCAL}; + +/// Upper bound on how long the fake runner waits for the client. +const TIMEOUT: Duration = Duration::from_secs(10); + +/// `vsock::Platform` for the fake runner. This test crate always has std, but +/// it shares one build of `vsock` with the client, and in the client's no-std +/// build that `vsock` is compiled without its `std` feature, so the ready-made +/// `vsock::Std` platform doesn't exist. This does the same thing. +struct TestPlatform; + +impl Platform for TestPlatform { + fn last_os_error() -> vsock::Error { + vsock::Error::SystemError(std::io::Error::last_os_error().raw_os_error().unwrap_or(0)) + } +} + +type Stream = VsockStream; +type Listener = VsockListener; + +/// The runner's side of the command server. Like the real runner, it reads one +/// request per connection. +struct RunnerConn { + listener: Listener, + stream: Option, +} + +impl RunnerConn { + fn read_request(&mut self) -> Request { + let (stream, _) = self.listener.accept().unwrap(); + stream.set_read_timeout(Some(TIMEOUT)).unwrap(); + let stream = self.stream.insert(stream); + let mut len = [0u8; size_of::()]; + stream.read_exact(&mut len).unwrap(); + let mut body = vec![0u8; usize::from_le_bytes(len)]; + stream.read_exact(&mut body).unwrap(); + serde_cbor::from_slice(&body).unwrap() + } + + /// The connection of the last request. + fn stream(&self) -> &Stream { + self.stream.as_ref().expect("no request read yet") + } + + fn send(&mut self, resp: &Response) { + let body = serde_cbor::ser::to_vec(resp).unwrap(); + self.stream().write_all(&body.len().to_le_bytes()).unwrap(); + self.stream().write_all(&body).unwrap(); + } +} +/// Starts a fake runner on a random vsock port. It accepts one command +/// connection and runs `script` on it. Returns the port, and the thread: +/// joining it re-raises any assertion that failed inside the script. +fn fake_runner(script: F) -> (u32, JoinHandle) +where + F: FnOnce(&mut RunnerConn) -> R + Send + 'static, + R: Send + 'static, +{ + let listener = Listener::bind_with_cid(VMADDR_CID_LOCAL) + .expect("cannot bind on vsock CID 1: is vsock_loopback loaded?"); + let port = listener.local_addr().unwrap().port(); + let handle = thread::spawn(move || { + script(&mut RunnerConn { listener, stream: None }) + }); + (port, handle) +} + +/// Accepts one connection on a raw listener fd returned by the client. +fn accept_on_fd(fd: i32) -> Stream { + let conn = unsafe { libc::accept(fd, std::ptr::null_mut(), std::ptr::null_mut()) }; + assert!(conn >= 0, "accept failed: {}", std::io::Error::last_os_error()); + unsafe { Stream::from_raw_fd(conn) } +} + +/// Built by hand: `From for Addr` needs fortanix-vme-abi's `core` +/// or `std` feature, which the client's no-std build doesn't enable. +fn ipv4(ip: [u8; 4], port: u16) -> Addr { + Addr::IPv4 { ip, port } +} + +// Requests that succeed + +#[test] +#[ignore = "needs vsock_loopback"] +fn args_returns_runner_args() { + let (port, runner) = fake_runner(|conn| { + assert_eq!(conn.read_request(), Request::Init); + conn.send(&Response::Init { args: vec!["enclave".into(), "--flag".into()] }); + }); + + assert_eq!(Client::new(port).args().unwrap(), ["enclave", "--flag"]); + runner.join().unwrap(); +} + +#[test] +#[ignore = "needs vsock_loopback"] +fn close_connection_sends_close() { + let (port, runner) = fake_runner(|conn| { + assert_eq!(conn.read_request(), Request::Close { enclave_port: 42 }); + conn.send(&Response::Closed); + }); + + Client::new(port).close_connection(42).unwrap(); + runner.join().unwrap(); +} + +#[test] +#[ignore = "needs vsock_loopback"] +fn open_proxy_connection_connects_to_proxy() { + let (port, runner) = fake_runner(|conn| { + assert_eq!(conn.read_request(), Request::Connect { addr: "example.com:80".into() }); + let proxy = Listener::bind_with_cid(VMADDR_CID_LOCAL).unwrap(); + conn.send(&Response::Connected { + proxy_port: proxy.local_addr().unwrap().port(), + local: ipv4([10, 0, 0, 2], 5000), + peer: ipv4([12, 34, 56, 78], 80), + }); + + // The client now connects to the proxy port. Echo what it sends. + let (stream, enclave_addr) = proxy.accept().unwrap(); + stream.set_read_timeout(Some(TIMEOUT)).unwrap(); + let mut buf = [0u8; 4]; + stream.read_exact(&mut buf).unwrap(); + stream.write_all(&buf).unwrap(); + enclave_addr.port() + }); + + let client = Client::new(port); + let (fd, info) = client.open_proxy_connection("example.com:80").unwrap(); + let (enclave_port, local, peer) = match info { + ConnectionInfo::Stream { enclave_port, local, peer } => (enclave_port, local, peer), + other => panic!("expected a stream, got {:?}", other), + }; + assert_eq!(local, ipv4([10, 0, 0, 2], 5000)); + assert_eq!(peer, ipv4([12, 34, 56, 78], 80)); + + // The returned fd is the client's end of the proxy connection. + let proxy = unsafe { Stream::from_raw_fd(fd) }; + proxy.write_all(b"ping").unwrap(); + let mut buf = [0u8; 4]; + proxy.read_exact(&mut buf).unwrap(); + assert_eq!(&buf, b"ping"); + + assert_eq!(runner.join().unwrap(), enclave_port, "enclave_port must be the client's port"); +} + +#[test] +#[ignore = "needs vsock_loopback"] +fn bind_socket_then_accept() { + let (port, runner) = fake_runner(|conn| { + let enclave_port = match conn.read_request() { + Request::Bind { addr, enclave_port } if addr == "0.0.0.0:8080" => enclave_port, + other => panic!("expected Bind for 0.0.0.0:8080, got {:?}", other), + }; + conn.send(&Response::Bound { local: ipv4([0, 0, 0, 0], 8080) }); + + // Like the real runner: reply first, then connect to the enclave's listener. + assert_eq!(conn.read_request(), Request::Accept { enclave_port }); + conn.send(&Response::IncomingConnection { + local: ipv4([10, 0, 0, 2], 8080), + peer: ipv4([10, 0, 0, 9], 40000), + proxy_port: 7777, + }); + let incoming = Stream::connect_with_cid_port(VMADDR_CID_LOCAL, enclave_port).unwrap(); + incoming.write_all(b"hello").unwrap(); + }); + + let client = Client::new(port); + let (fd, info) = client.bind_socket("0.0.0.0:8080").unwrap(); + let (local, enclave_port) = match info { + ConnectionInfo::Listener { local, enclave_port } => (local, enclave_port), + other => panic!("expected a listener, got {:?}", other), + }; + assert_eq!(local, ipv4([0, 0, 0, 0], 8080)); + + let (local, peer, proxy_port) = client.accept(enclave_port).unwrap(); + assert_eq!(local, ipv4([10, 0, 0, 2], 8080)); + assert_eq!(peer, ipv4([10, 0, 0, 9], 40000)); + assert_eq!(proxy_port, 7777); + + // The returned fd is a real listener: the runner's connection arrives on it. + let stream = accept_on_fd(fd); + let mut buf = [0u8; 5]; + stream.read_exact(&mut buf).unwrap(); + assert_eq!(&buf, b"hello"); + + runner.join().unwrap(); +} + +// Failures + +#[test] +#[ignore = "needs vsock_loopback"] +fn no_runner_reports_errno() { + // Bind and drop a listener to get a port nobody listens on. + let port = Listener::bind_with_cid(VMADDR_CID_LOCAL).unwrap().local_addr().unwrap().port(); + + // A real errno (> 0) shows that `ClientPlatform` reads errno correctly. In the + // no-std build, that is the `libc::__errno_location` path. + match Client::new(port).args() { + Err(Error::SystemError(errno)) if errno > 0 => {} + other => panic!("expected SystemError(errno > 0), got {:?}", other.err()), + } +} + +#[test] +#[ignore = "needs vsock_loopback"] +fn runner_command_error_is_returned() { + let (port, runner) = fake_runner(|conn| { + conn.read_request(); + conn.send(&Response::Failed(RunnerError::Command(ErrorKind::ConnectionRefused))); + }); + + let client = Client::new(port); + let err = client.open_proxy_connection("example.com:80").unwrap_err(); + assert_eq!(err, Error::IoError(ErrorKind::ConnectionRefused)); + runner.join().unwrap(); +} + +#[test] +#[ignore = "needs vsock_loopback"] +fn connection_not_found_is_an_error() { + let (port, runner) = fake_runner(|conn| { + conn.read_request(); + conn.send(&Response::Failed(RunnerError::ConnectionNotFound)); + }); + + let result = Client::new(port).close_connection(42); + assert!(matches!(result, Err(Error::Other(_))), "got {:?}", result); + runner.join().unwrap(); +} + +#[test] +#[ignore = "needs vsock_loopback"] +fn wrong_reply_is_invalid_data() { + let (port, runner) = fake_runner(|conn| { + assert_eq!(conn.read_request(), Request::Init); + conn.send(&Response::Closed); + }); + + assert_eq!(Client::new(port).args(), Err(Error::IoError(ErrorKind::InvalidData))); + runner.join().unwrap(); +} + +#[test] +#[ignore = "needs vsock_loopback"] +fn runner_hanging_up_mid_reply_is_unexpected_eof() { + let (port, runner) = fake_runner(|conn| { + conn.read_request(); + // Announce a 100-byte body, then close the connection. + conn.stream().write_all(&100usize.to_le_bytes()).unwrap(); + }); + + assert_eq!(Client::new(port).args(), Err(Error::IoError(ErrorKind::UnexpectedEof))); + runner.join().unwrap(); +} diff --git a/fortanix-vme/fortanix-vme-abi/Cargo.toml b/fortanix-vme/fortanix-vme-abi/Cargo.toml index 7babfac08..238f58543 100644 --- a/fortanix-vme/fortanix-vme-abi/Cargo.toml +++ b/fortanix-vme/fortanix-vme-abi/Cargo.toml @@ -9,7 +9,7 @@ authors = ["Fortanix, Inc."] [dependencies] core = { version = "1.0.0", optional = true, package = "rustc-std-workspace-core" } alloc = { version = "1.0.0", optional = true, package = "rustc-std-workspace-alloc" } -serde = { version = "1.0", default-features = false, optional = true } +serde = { version = "1.0", default-features = false, optional = true, features = ["alloc"] } thiserror = { version = "2.0", optional = true } [dev-dependencies] diff --git a/fortanix-vme/fortanix-vme-abi/src/lib.rs b/fortanix-vme/fortanix-vme-abi/src/lib.rs index 7a8ad3b97..c538ff818 100644 --- a/fortanix-vme/fortanix-vme-abi/src/lib.rs +++ b/fortanix-vme/fortanix-vme-abi/src/lib.rs @@ -3,22 +3,16 @@ #[cfg(feature="std")] extern crate std; +#[cfg_attr(feature = "rustc-dep-of-std", allow(unused_extern_crates))] +extern crate alloc; -#[cfg(all(feature="alloc", not(feature="std")))] +// std types are just re-exports of alloc/core types. Conditional compilation is not necessary here, +// and it allows clean compilation even with no features enabled. use { alloc::string::String, alloc::vec::Vec, }; -#[cfg(all(feature="std", not(feature="alloc")))] -use { - std::string::String, - std::vec::Vec, -}; - -#[cfg(feature="core")] use core::net::{IpAddr, SocketAddr}; -#[cfg(all(feature="std", not(feature="core")))] -use std::net::{IpAddr, SocketAddr}; #[cfg(feature="std")] use std::io; @@ -99,7 +93,6 @@ impl From for Addr { } } -#[cfg(any(feature="core", feature="std"))] impl From for SocketAddr { fn from(addr: Addr) -> SocketAddr { match addr { diff --git a/intel-sgx/aesm-client/Cargo.toml b/intel-sgx/aesm-client/Cargo.toml index 942dc6999..bd5653dd0 100644 --- a/intel-sgx/aesm-client/Cargo.toml +++ b/intel-sgx/aesm-client/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "aesm-client" version = "0.6.3" +edition = "2015" authors = ["Fortanix, Inc."] license = "MPL-2.0" description = """ diff --git a/intel-sgx/dcap-artifact-retrieval/Cargo.toml b/intel-sgx/dcap-artifact-retrieval/Cargo.toml index 829740ebf..516e67af2 100644 --- a/intel-sgx/dcap-artifact-retrieval/Cargo.toml +++ b/intel-sgx/dcap-artifact-retrieval/Cargo.toml @@ -45,9 +45,4 @@ rustls-tls = ["reqwest?/rustls-tls"] [dev-dependencies] assert_matches = "1.5.0" yasna = { version = "0.3", features = ["num-bigint", "bit-vec"] } -pcs = { version = "0.8.3", path = "../pcs", features = ["verify"] } - -[build-dependencies] -mbedtls = { version = ">=0.12.0, <0.14.0", features = ["ssl", "x509"] } -pkix = "0.2.0" -serde_cbor = "0.11" +pcs = { version = "0.8.3", path = "../pcs", features = ["verify"] } \ No newline at end of file diff --git a/intel-sgx/dcap-ql-sys/Cargo.toml b/intel-sgx/dcap-ql-sys/Cargo.toml index 3dd18a196..aa6dd51cc 100644 --- a/intel-sgx/dcap-ql-sys/Cargo.toml +++ b/intel-sgx/dcap-ql-sys/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "dcap-ql-sys" version = "0.2.3" +edition = "2015" authors = ["Fortanix, Inc."] links = "sgx_dcap_ql" build = "build.rs" diff --git a/intel-sgx/dcap-ql/Cargo.toml b/intel-sgx/dcap-ql/Cargo.toml index 1c863b7bf..dc95c44ad 100644 --- a/intel-sgx/dcap-ql/Cargo.toml +++ b/intel-sgx/dcap-ql/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "dcap-ql" version = "0.4.3" +edition = "2015" authors = ["Fortanix, Inc."] license = "MPL-2.0" description = """ diff --git a/intel-sgx/fortanix-sgx-abi/Cargo.toml b/intel-sgx/fortanix-sgx-abi/Cargo.toml index 9ca5be9ed..0e9529603 100644 --- a/intel-sgx/fortanix-sgx-abi/Cargo.toml +++ b/intel-sgx/fortanix-sgx-abi/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "fortanix-sgx-abi" version = "0.6.1" +edition = "2015" authors = ["Fortanix, Inc."] license = "MPL-2.0" description = """ diff --git a/intel-sgx/report-test/Cargo.toml b/intel-sgx/report-test/Cargo.toml index 29c22e0ed..44b46b3f0 100644 --- a/intel-sgx/report-test/Cargo.toml +++ b/intel-sgx/report-test/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "report-test" version = "0.5.3" +edition = "2015" authors = ["Fortanix, Inc."] license = "MPL-2.0" description = """ diff --git a/intel-sgx/sgx-isa/Cargo.toml b/intel-sgx/sgx-isa/Cargo.toml index 18858fff4..24cb3cc77 100644 --- a/intel-sgx/sgx-isa/Cargo.toml +++ b/intel-sgx/sgx-isa/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "sgx-isa" version = "0.6.0" +edition = "2015" authors = ["Fortanix, Inc."] license = "MPL-2.0" description = """ diff --git a/intel-sgx/sgxs/Cargo.toml b/intel-sgx/sgxs/Cargo.toml index 726bba0a4..7975dee9d 100644 --- a/intel-sgx/sgxs/Cargo.toml +++ b/intel-sgx/sgxs/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "sgxs" version = "0.9.0" +edition = "2015" authors = ["Fortanix, Inc."] license = "MPL-2.0" description = """ diff --git a/rs-libc/Cargo.toml b/rs-libc/Cargo.toml index 860cd1936..66987726d 100644 --- a/rs-libc/Cargo.toml +++ b/rs-libc/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "rs-libc" version = "0.2.5" +edition = "2015" authors = ["Fortanix, Inc."] license-file = "LICENSE" description = """