[LibOS] Fix shim_ipc_info leak

This PR has one caveat: it makes pids reusable i.e. they might not be
growing (Graphene might reuse old, freed pids).
This commit is contained in:
borysp
2020-11-30 10:44:36 +01:00
parent 633cc239a2
commit 1798e3870b
3 changed files with 7 additions and 2 deletions
+3
View File
@@ -77,6 +77,9 @@ struct shim_child_process* create_child_process(void) {
void destroy_child_process(struct shim_child_process* child) {
assert(LIST_EMPTY(child, list));
/* This only removes the pid from internal IPC tracking in this process. */
release_ipc_id(child->pid);
free(child);
}
+1 -1
View File
@@ -272,7 +272,7 @@ static int add_ipc_range(IDTYPE base, IDTYPE owner, const char* uri) {
static void __del_ipc_subrange(struct subrange** ptr) {
struct subrange* s = *ptr;
*ptr = NULL;
put_ipc_info(s->owner);
put_ipc_info_in_list(s->owner);
free(s);
nsubed--;
}
+3 -1
View File
@@ -369,7 +369,9 @@ long shim_do_clone(unsigned long flags, unsigned long user_stack_addr, int* pare
/* We should not have saved any references to this thread anywhere and `put_thread` below
* should free it. */
assert(__atomic_load_n(&thread->ref_count.counter, __ATOMIC_RELAXED) == 1);
/* We do not want to release `tid`, now it's owned by child process. */
/* We do not want to release `tid` now, we will do this once the child process dies. This
* makes little sense (as in theory we've passed the ownership of this id to the child), but
* IPC code is a mess, so that's what we have to do. */
thread->tid = 0;
put_thread(thread);