1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 21:38:11 +00:00

Kernel: Copy over TLS region size and alignment when forking

Previously we would unintentionally leave them zero-initialized,
resulting in any threads created post fork (but without execve) having
invalid thread local storage pointers stored in their FS register.
This commit is contained in:
Idan Horowitz 2023-12-15 19:15:57 +02:00 committed by Andreas Kling
parent b35ebd31a4
commit 2a6b492c7f

View file

@ -168,8 +168,11 @@ ErrorOr<FlatPtr> Process::sys$fork(RegisterState& regs)
TRY(child_space->region_tree().place_specifically(*region_clone, region.range()));
auto* child_region = region_clone.leak_ptr();
if (&region == m_master_tls_region.unsafe_ptr())
if (&region == m_master_tls_region.unsafe_ptr()) {
child->m_master_tls_region = TRY(child_region->try_make_weak_ptr());
child->m_master_tls_size = m_master_tls_size;
child->m_master_tls_alignment = m_master_tls_alignment;
}
}
return {};
});