diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-11-02 16:34:38 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-11-02 16:34:38 +0200 |
| commit | 17fd9daf39cf79ae310c1b7d0eb459802517dc6a (patch) | |
| tree | 1f9061bc489289769d134e97efea805cbf1bf29a /src | |
| parent | 010152de4f19fcb4f1b627123aa27f08deb13e72 (diff) | |
| download | kmi-17fd9daf39cf79ae310c1b7d0eb459802517dc6a.tar.gz kmi-17fd9daf39cf79ae310c1b7d0eb459802517dc6a.zip | |
check spawn exhaustion
Diffstat (limited to 'src')
| -rw-r--r-- | src/regions.c | 6 | ||||
| -rw-r--r-- | src/uapi/proc.c | 10 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/regions.c b/src/regions.c index 2c11db0..163ec82 100644 --- a/src/regions.c +++ b/src/regions.c @@ -35,6 +35,9 @@ void destroy_mem_nodes() static struct mem_region *get_mem_node() { struct mem_region *r = get_node(&root); + if (!r) + return NULL; + memset(r, 0, sizeof(struct mem_region)); return r; } @@ -178,6 +181,9 @@ stat_t init_region(struct mem_region_root *r, vm_t start, size_t arena_size, start = __page(start); arena_size = __page(arena_size); struct mem_region *m = get_mem_node(); + if (!m) + return ERR_OOMEM; + m->start = start; m->end = start + arena_size; m->flags = 0; diff --git a/src/uapi/proc.c b/src/uapi/proc.c index 51a1252..5eb3013 100644 --- a/src/uapi/proc.c +++ b/src/uapi/proc.c @@ -154,11 +154,15 @@ SYSCALL_DEFINE2(spawn)(struct tcb *t, sys_arg_t bin, sys_arg_t interp) if (!n) return_args1(t, ERR_OOMEM); + /** @todo there's currently a kind of silly thing where create_proc() + * creates a new thread and calls init_uvmem() on it, and now the elf + * loader called from prepare_proc() moves that uvmem aside, calls + * init_uvmem() again and finally destroys the old uvmem (assuming + * everything went as it was supposed to). Might have to rething these + * internal APIs a bit, but for now this ~works~. */ n->notify_id = c->notify_id; if (prepare_proc(n, bin, interp)) { - /* this kills the thread */ - orphanize(t); - unorphanize(t); + destroy_proc(n); return_args1(t, ERR_INVAL); } |
