Skip to content

Commit

Permalink
Add mio_unsupported_force_waker_pipe cfg flag
Browse files Browse the repository at this point in the history
This, unsupported, 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 25, 2023
1 parent 2f61857 commit ec0776f
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions src/sys/unix/waker.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#[cfg(any(target_os = "linux", target_os = "android"))]
#[cfg(all(
not(mio_unsupported_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_unsupported_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_unsupported_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_unsupported_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_unsupported_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_unsupported_force_waker_pipe,
target_os = "dragonfly",
target_os = "illumos",
target_os = "netbsd",
Expand Down

0 comments on commit ec0776f

Please sign in to comment.