Skip to content
Snippets Groups Projects
Verified Commit 8f66730d authored by Jacob Lorentzon's avatar Jacob Lorentzon
Browse files

Set child sighandler *after* cloning address space.

parent 20284eb2
No related branches found
No related tags found
No related merge requests found
......@@ -713,12 +713,6 @@ pub fn fork_inner(initial_rsp: *mut usize) -> Result<usize> {
let cur_pid_fd = FdGuard::new(syscall::open("thisproc:current/open_via_dup", O_CLOEXEC)?);
(new_pid_fd, new_pid) = new_context()?;
// Reuse the same sigaltstack and signal entry (all memory will be re-mapped CoW later).
{
let new_sighandler_fd = FdGuard::new(syscall::dup(*new_pid_fd, b"sighandler")?);
let _ = syscall::write(*new_sighandler_fd, &crate::signal::current_setsighandler_struct())?;
}
copy_str(*cur_pid_fd, *new_pid_fd, "name")?;
// Copy existing files into new file table, but do not reuse the same file table (i.e. new
......@@ -801,6 +795,15 @@ pub fn fork_inner(initial_rsp: *mut usize) -> Result<usize> {
}
}
// Reuse the same sigaltstack and signal entry (all memory will be re-mapped CoW later).
//
// Do this after the address space is cloned, since the kernel will get a shared
// reference to the TCB and whatever pages stores the signal proc control struct.
{
let new_sighandler_fd = FdGuard::new(syscall::dup(*new_pid_fd, b"sighandler")?);
let _ = syscall::write(*new_sighandler_fd, &crate::signal::current_setsighandler_struct())?;
}
let buf = create_set_addr_space_buf(
*new_addr_space_fd,
__relibc_internal_fork_ret as usize,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment