From 7e828ec1e1479ff9a8afe845539d08ca0dfada5f Mon Sep 17 00:00:00 2001 From: Kimplul Date: Mon, 8 Jul 2024 17:38:59 +0300 Subject: add orphan checking to timer and irq handling --- src/uapi/proc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/uapi/proc.c') diff --git a/src/uapi/proc.c b/src/uapi/proc.c index 293a01f..eddbab8 100644 --- a/src/uapi/proc.c +++ b/src/uapi/proc.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -127,7 +128,18 @@ SYSCALL_DEFINE2(exec)(struct tcb *t, sys_arg_t bin, sys_arg_t interp) if (interp) clear_bit(b->flags, MR_KEEP); - return_args1(t, prepare_proc(t, bin, interp)); + /* should hopefully never actually fail, but if it does, we don't really + * have any choice but to kill the thread. */ + if (prepare_proc(t, bin, interp)) { + /* this kills the thread */ + orphanize(t); + unorphanize(t); + /* should never be reached as we control the thread so we should + * be able to directly jump to pid 1 */ + assert(false); + } + + return_args4(t, 0, t->tid, SYS_USER_SPAWNED, t->pid); } /** -- cgit v1.3