Skip to content

Commit

Permalink
Add mio_unspported_force_waker_pipe cfg flag
Browse files Browse the repository at this point in the history
This, unuspported, flag forces the Waker implementation to use the pipe
implementation.

This is required because some SGX runtimes like gramine do not have a
secure emulation of the `eventfd` syscall, compiling with this flag will
produce a more secure SGX application.

See also:
https://gramine.readthedocs.io/en/stable/manifest-syntax.html#allowing-eventfd

Co-authored-by: Thomas de Zeeuw <thomasdezeeuw@gmail.com>
  • Loading branch information
haraldh and Thomasdezeeuw committed Jun 24, 2023
1 parent c2f79f6 commit 0674e24
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions src/sys/unix/waker.rs
@@ -1,4 +1,7 @@
#[cfg(any(target_os = "linux", target_os = "android"))]
#[cfg(all(
not(mio_unspported_force_waker_pipe),
any(target_os = "linux", target_os = "android")
))]
mod eventfd {
use crate::sys::Selector;
use crate::{Interest, Token};
Expand Down Expand Up @@ -55,15 +58,21 @@ mod eventfd {
}
}

#[cfg(any(target_os = "linux", target_os = "android"))]
#[cfg(all(
not(mio_unspported_force_waker_pipe),
any(target_os = "linux", target_os = "android")
))]
pub use self::eventfd::Waker;

#[cfg(any(
target_os = "freebsd",
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
#[cfg(all(
not(mio_unspported_force_waker_pipe),
any(
target_os = "freebsd",
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
)
))]
mod kqueue {
use crate::sys::Selector;
Expand Down Expand Up @@ -96,16 +105,20 @@ mod kqueue {
}
}

#[cfg(any(
target_os = "freebsd",
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
#[cfg(all(
not(mio_unspported_force_waker_pipe),
any(
target_os = "freebsd",
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
)
))]
pub use self::kqueue::Waker;

#[cfg(any(
mio_unspported_force_waker_pipe,
target_os = "dragonfly",
target_os = "illumos",
target_os = "netbsd",
Expand Down Expand Up @@ -176,6 +189,7 @@ mod pipe {
}

#[cfg(any(
mio_unspported_force_waker_pipe,
target_os = "dragonfly",
target_os = "illumos",
target_os = "netbsd",
Expand Down

0 comments on commit 0674e24

Please sign in to comment.