@@ -25,7 +25,6 @@ use hyperlight_common::flatbuffer_wrappers::host_function_details::HostFunctionD
2525use termcolor:: { Color , ColorChoice , ColorSpec , StandardStream , WriteColor } ;
2626use tracing:: { Span , instrument} ;
2727
28- use super :: ExtraAllowedSyscall ;
2928use crate :: HyperlightError :: HostFunctionNotFound ;
3029use crate :: func:: host_functions:: TypeErasedHostFunction ;
3130use crate :: mem:: mgr:: SandboxMemoryManager ;
@@ -58,7 +57,6 @@ impl From<&mut FunctionRegistry> for HostFunctionDetails {
5857
5958pub struct FunctionEntry {
6059 pub function : TypeErasedHostFunction ,
61- pub extra_allowed_syscalls : Option < Vec < ExtraAllowedSyscall > > ,
6260 pub parameter_types : & ' static [ ParameterType ] ,
6361 pub return_type : ReturnType ,
6462}
@@ -119,18 +117,15 @@ impl FunctionRegistry {
119117 fn call_host_func_impl ( & self , name : & str , args : Vec < ParameterValue > ) -> Result < ReturnValue > {
120118 let FunctionEntry {
121119 function,
122- extra_allowed_syscalls,
123120 parameter_types : _,
124121 return_type : _,
125122 } = self
126123 . functions_map
127124 . get ( name)
128125 . ok_or_else ( || HostFunctionNotFound ( name. to_string ( ) ) ) ?;
129126
130- // Create a new thread when seccomp is enabled on Linux
131- maybe_with_seccomp ( name, extra_allowed_syscalls. as_deref ( ) , || {
132- crate :: metrics:: maybe_time_and_emit_host_call ( name, || function. call ( args) )
133- } )
127+ // Make the host function call
128+ crate :: metrics:: maybe_time_and_emit_host_call ( name, || function. call ( args) )
134129 }
135130}
136131
@@ -153,58 +148,3 @@ pub(super) fn default_writer_func(s: String) -> Result<i32> {
153148 }
154149 }
155150}
156-
157- #[ cfg( seccomp) ]
158- fn maybe_with_seccomp < T : Send > (
159- name : & str ,
160- syscalls : Option < & [ ExtraAllowedSyscall ] > ,
161- f : impl FnOnce ( ) -> Result < T > + Send ,
162- ) -> Result < T > {
163- use std:: thread;
164-
165- use crate :: seccomp:: guest:: get_seccomp_filter_for_host_function_worker_thread;
166-
167- // Use a scoped thread so that we can pass around references without having to clone them.
168- thread:: scope ( |s| {
169- thread:: Builder :: new ( )
170- . name ( format ! ( "Host Function Worker Thread for: {name:?}" ) )
171- . spawn_scoped ( s, move || {
172- let seccomp_filter = get_seccomp_filter_for_host_function_worker_thread ( syscalls) ?;
173- seccomp_filter
174- . iter ( )
175- . try_for_each ( |filter| seccompiler:: apply_filter ( filter) ) ?;
176-
177- // We have a `catch_unwind` here because, if a disallowed syscall is issued,
178- // we handle it by panicking. This is to avoid returning execution to the
179- // offending host function—for two reasons: (1) if a host function is issuing
180- // disallowed syscalls, it could be unsafe to return to, and (2) returning
181- // execution after trapping the disallowed syscall can lead to UB (e.g., try
182- // running a host function that attempts to sleep without `SYS_clock_nanosleep`,
183- // you'll block the syscall but panic in the aftermath).
184- match std:: panic:: catch_unwind ( std:: panic:: AssertUnwindSafe ( f) ) {
185- Ok ( val) => val,
186- Err ( err) => {
187- if let Some ( crate :: HyperlightError :: DisallowedSyscall ) =
188- err. downcast_ref :: < crate :: HyperlightError > ( )
189- {
190- return Err ( crate :: HyperlightError :: DisallowedSyscall ) ;
191- }
192-
193- crate :: log_then_return!( "Host function {} panicked" , name) ;
194- }
195- }
196- } ) ?
197- . join ( )
198- . map_err ( |_| new_error ! ( "Error joining thread executing host function" ) ) ?
199- } )
200- }
201-
202- #[ cfg( not( seccomp) ) ]
203- fn maybe_with_seccomp < T : Send > (
204- _name : & str ,
205- _syscalls : Option < & [ ExtraAllowedSyscall ] > ,
206- f : impl FnOnce ( ) -> Result < T > + Send ,
207- ) -> Result < T > {
208- // No seccomp, just call the function
209- f ( )
210- }
0 commit comments