Skip to content

Commit

Permalink
Duplicate Heap structure on execve if it's shared
Browse files Browse the repository at this point in the history
When parent uses vfork() and then child performs execve()
we previously just cleared heap struct which was shared
in case of vfork() and it remained shared between parent and child

Now during execve when Heap structure is shared we create new one
and unlink child from parent Heap
  • Loading branch information
michalbednarski committed Aug 27, 2017
1 parent ccf3d7a commit 6671bfe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/execve/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,14 @@ void translate_execve_exit(Tracee *tracee)
}

/* New processes have no heap. */
bzero(tracee->heap, sizeof(Heap));
if (talloc_reference_count(tracee->heap) >= 1) {
talloc_unlink(tracee, tracee->heap);
tracee->heap = talloc_zero(tracee, Heap);
if (tracee->heap == NULL)
note(tracee, ERROR, INTERNAL, "can't alloc heap after execve");
} else {
bzero(tracee->heap, sizeof(Heap));
}

/* Transfer the load script to the loader. */
status = transfer_load_script(tracee);
Expand Down

0 comments on commit 6671bfe

Please sign in to comment.