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:
@@ -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.
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user