mirror of
https://github.com/clearlinux/graphene.git
synced 2026-08-22 05:56:23 +00:00
[LibOS] clone shouldn't expose child thread until its init
The final initialization of child thread of clone is done by clone_implementation_wrapper(). Until the initialization completes, child shim_thread shouldn't be exposed to other thread. Otherwise other thread can access uninitialized shim_thread. For example, other thread tries to send signal to that thread by walking thread_list and access uninitialized member of shim_thread. Defer add_thread() until initialization is complete. Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
This commit is contained in:
committed by
Don Porter
parent
8d3569dabc
commit
9ea009ab6f
@@ -129,6 +129,10 @@ int clone_implementation_wrapper(struct clone_args * arg)
|
||||
my_thread->stack_top = vma.addr + vma.length;
|
||||
my_thread->stack_red = my_thread->stack = vma.addr;
|
||||
|
||||
/* until now we're not ready to be exposed to other thread */
|
||||
add_thread(my_thread);
|
||||
set_as_child(arg->parent, my_thread);
|
||||
|
||||
/* Don't signal the initialize event until we are actually init-ed */
|
||||
DkEventSet(pcargs->initialize_event);
|
||||
|
||||
@@ -324,8 +328,6 @@ int shim_do_clone (int flags, void * user_stack_addr, int * parent_tidptr,
|
||||
|
||||
thread->pal_handle = pal_handle;
|
||||
thread->in_vm = thread->is_alive = true;
|
||||
add_thread(thread);
|
||||
set_as_child(self, thread);
|
||||
|
||||
if (set_parent_tid)
|
||||
*set_parent_tid = tid;
|
||||
|
||||
Reference in New Issue
Block a user