From ec0776f5af29548e4e1f48f86f5fa123a46caa07 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Sat, 24 Jun 2023 13:16:22 +0200 Subject: [PATCH] Add mio_unsupported_force_waker_pipe cfg flag 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 --- src/sys/unix/waker.rs | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/sys/unix/waker.rs b/src/sys/unix/waker.rs index 0044cd06d..65002d690 100644 --- a/src/sys/unix/waker.rs +++ b/src/sys/unix/waker.rs @@ -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}; @@ -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; @@ -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", @@ -176,6 +189,7 @@ mod pipe { } #[cfg(any( + mio_unsupported_force_waker_pipe, target_os = "dragonfly", target_os = "illumos", target_os = "netbsd",