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,
|
&extrainfo,
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.ok()
|
.unwrap_or_else(|e| {
|
||||||
.flatten()
|
let step = unsafe { redox_rt::proc::FEXEC_STEP };
|
||||||
.expect("failed to execute init");
|
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
|
// According to elf(5), PT_INTERP requires that the interpreter path be
|
||||||
// null-terminated. Violating this should therefore give the "format error" ENOEXEC.
|
// null-terminated. Violating this should therefore give the "format error" ENOEXEC.
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ impl SchemeSync for InitFsScheme {
|
|||||||
) -> Result<OpenResult> {
|
) -> Result<OpenResult> {
|
||||||
if !matches!(
|
if !matches!(
|
||||||
self.handles.get(&dirfd).ok_or(Error::new(EBADF))?,
|
self.handles.get(&dirfd).ok_or(Error::new(EBADF))?,
|
||||||
Handle::SchemeRoot
|
Handle::SchemeRoot | Handle::Node(_)
|
||||||
) {
|
) {
|
||||||
return Err(Error::new(EACCES));
|
return Err(Error::new(EACCES));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,12 @@ pub fn run(write_fd: FdGuard, socket: Socket, auth: FdGuard, event: FdGuard) ->
|
|||||||
// TODO?
|
// TODO?
|
||||||
let socket_ident = socket.inner().raw();
|
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");
|
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);
|
drop(event);
|
||||||
|
|
||||||
queue
|
queue
|
||||||
|
|||||||
Reference in New Issue
Block a user