Fix rlct_clone.

This commit is contained in:
4lDO2
2024-06-23 11:15:16 +02:00
parent 42c24dd755
commit 20284eb2b2
2 changed files with 7 additions and 31 deletions
+1 -1
View File
@@ -106,7 +106,7 @@ asmfunction!(__relibc_internal_fork_ret: ["
pop rbp
ret
"] <= []);
asmfunction!(__relibc_internal_rlct_clone_ret -> usize: ["
asmfunction!(__relibc_internal_rlct_clone_ret: ["
# Load registers
pop rax
pop rdi
+6 -30
View File
@@ -19,13 +19,13 @@ pub unsafe fn rlct_clone_impl(stack: *mut usize) -> Result<usize> {
let buf = create_set_addr_space_buf(
*cur_addr_space_fd,
__relibc_internal_rlct_clone_ret() as usize,
__relibc_internal_rlct_clone_ret as usize,
stack as usize,
);
let _ = syscall::write(*new_addr_space_sel_fd, &buf)?;
}
// Inherit file table
// Inherit reference to file table
{
let cur_filetable_fd = FdGuard::new(syscall::dup(*cur_pid_fd, b"filetable")?);
let new_filetable_sel_fd = FdGuard::new(syscall::dup(*new_pid_fd, b"current-filetable")?);
@@ -36,34 +36,10 @@ pub unsafe fn rlct_clone_impl(stack: *mut usize) -> Result<usize> {
)?;
}
// Inherit sigactions (on Linux, CLONE_THREAD requires CLONE_SIGHAND which implies the sigactions
// table is reused).
{
let cur_sigaction_fd = FdGuard::new(syscall::dup(*cur_pid_fd, b"sigactions")?);
let new_sigaction_sel_fd = FdGuard::new(syscall::dup(*new_pid_fd, b"current-sigactions")?);
let _ = syscall::write(
*new_sigaction_sel_fd,
&usize::to_ne_bytes(*cur_sigaction_fd),
)?;
}
// Inherit sighandler, but not the sigaltstack.
{
let new_sighandler_fd = FdGuard::new(syscall::dup(*new_pid_fd, b"sighandler")?);
let data = SetSighandlerData {
user_handler: sighandler_function(),
excp_handler: 0,
thread_control_addr: 0, // TODO
proc_control_addr: 0, // TODO
};
let _ = syscall::write(*new_sighandler_fd, &data)?;
}
// Sigprocmask starts as "block all", and is initialized when the thread has actually returned
// from clone_ret.
// TODO: Should some of these registers be inherited?
//copy_env_regs(*cur_pid_fd, *new_pid_fd)?;
// Since the signal handler is not yet initialized, signals specifically targeting the thread
// (relibc is only required to implement thread-specific signals that already originate from
// the same process) will be discarded. Process-specific signals will ignore this new thread,
// until it has initialized its own signal handler.
// Unblock context.
let start_fd = FdGuard::new(syscall::dup(*new_pid_fd, b"start")?);