File tree Expand file tree Collapse file tree
native/suidhelper/src/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -298,8 +298,19 @@ impl Jailer<'_> {
298298/// closing each fd individually — fail closed before handing root to the jailer.
299299fn close_inherited_fds ( ) {
300300 const FIRST : u32 = 3 ;
301+ // Invoke `close_range(2)` as a raw syscall rather than through the
302+ // `libc::close_range` wrapper: the `libc` crate does not define that wrapper
303+ // for every target (it is absent on aarch64-musl), but `SYS_close_range` is
304+ // defined on all Linux arches. `syscall` returns 0 on success, -1 on error.
301305 // SAFETY: raw syscall with no memory operands; closing fds has no UB.
302- let rc = unsafe { nix:: libc:: close_range ( FIRST , u32:: MAX , 0 ) } ;
306+ let rc = unsafe {
307+ nix:: libc:: syscall (
308+ nix:: libc:: SYS_close_range ,
309+ FIRST as nix:: libc:: c_uint ,
310+ u32:: MAX as nix:: libc:: c_uint ,
311+ 0 as nix:: libc:: c_uint ,
312+ )
313+ } ;
303314 if rc == 0 {
304315 return ;
305316 }
You can’t perform that action at this time.
0 commit comments