fix: register external fds with userspace FILETABLE

Socket and RawEventQueue create fds via libredox raw syscalls that
bypass the redox-rt userspace FILETABLE. FdGuard::dup then reserves
these positions, causing SYS_DUP_INTO to destroy the existing fds.
This commit is contained in:
Red Bear OS
2026-07-12 08:15:00 +03:00
parent 7ba6cff32d
commit ab0da30613
3 changed files with 14 additions and 4 deletions
+8 -3
View File
@@ -253,9 +253,14 @@ pub fn main() -> ! {
&extrainfo,
None,
)
.ok()
.flatten()
.expect("failed to execute init");
.unwrap_or_else(|e| {
let step = unsafe { redox_rt::proc::FEXEC_STEP };
panic!("fexec_impl error: {:?} at step {}", e, step);
})
.unwrap_or_else(|| panic!("fexec_impl returned None (no interpreter)"))
else {
panic!("fexec_impl returned unexpected variant");
};
// According to elf(5), PT_INTERP requires that the interpreter path be
// null-terminated. Violating this should therefore give the "format error" ENOEXEC.
+1 -1
View File
@@ -123,7 +123,7 @@ impl SchemeSync for InitFsScheme {
) -> Result<OpenResult> {
if !matches!(
self.handles.get(&dirfd).ok_or(Error::new(EBADF))?,
Handle::SchemeRoot
Handle::SchemeRoot | Handle::Node(_)
) {
return Err(Error::new(EACCES));
}
+5
View File
@@ -49,7 +49,12 @@ pub fn run(write_fd: FdGuard, socket: Socket, auth: FdGuard, event: FdGuard) ->
// TODO?
let socket_ident = socket.inner().raw();
redox_rt::proc::register_external_fd(socket.inner().raw())
.expect("failed to register socket fd with userspace filetable");
let queue = RawEventQueue::new(event.as_raw_fd()).expect("failed to create event queue");
redox_rt::proc::register_external_fd(queue.0.as_raw_fd())
.expect("failed to register event queue fd with userspace filetable");
drop(event);
queue