[CRITICAL] FD leak to child processes -- hardcoded 1024 limit #18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
In
process.rs, thepre_execclosure closes inherited FDs 3..1024. This hardcoded limit means any FD numbered 1024 or higher leaks to child processes.On a busy server, the supervisor can easily open FDs beyond 1024:
Impact
Files
crates/my_init_server/src/process.rs--pre_execclosure inspawn_processSuggested Fix
Use
posix_closefrom(3)(Linux 3.17+) or iterate/proc/self/fdto close all FDs beyond 2. This removes the hardcoded limit entirely.Confirmed by code inspection at crates/my_init_server/src/process.rs:389. The pre_exec closure iterates for fd in 3..1024 { libc::close(fd); }. On servers with many IPC connections, log files, cgroup FDs, and sockets, FDs can easily exceed 1024. These leaked FDs allow child processes to inherit my_init's internal sockets (IPC, syslog), potentially enabling communication with the supervisor from compromised services. The fix is to use close_range() or iterate /proc/self/fd.