Skip to content

Commit 2a6b492

Browse files
IdanHoawesomekling
authored andcommitted
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.
1 parent b35ebd3 commit 2a6b492

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Kernel/Syscalls/fork.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,11 @@ ErrorOr<FlatPtr> Process::sys$fork(RegisterState& regs)
168168
TRY(child_space->region_tree().place_specifically(*region_clone, region.range()));
169169
auto* child_region = region_clone.leak_ptr();
170170

171-
if (&region == m_master_tls_region.unsafe_ptr())
171+
if (&region == m_master_tls_region.unsafe_ptr()) {
172172
child->m_master_tls_region = TRY(child_region->try_make_weak_ptr());
173+
child->m_master_tls_size = m_master_tls_size;
174+
child->m_master_tls_alignment = m_master_tls_alignment;
175+
}
173176
}
174177
return {};
175178
});

0 commit comments

Comments
 (0)