commit 6e09d19535fdb94f2ed751bee214c6a8dfa7399b
parent 195855ac4daa9ce7119c4eff9ae2f011d6e01df6
Author: Roberto E. Vargas Caballero <roberto.vargas@midokura.com>
Date: Thu, 17 Nov 2022 07:58:02 +0100
os9: Fix locking around clone()
Clone() calls newtask() that cannot be called with
any task locked.
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/os9/proc.c b/src/os9/proc.c
@@ -349,6 +349,8 @@ clone(Task *parent)
if (!initptable(tp) || !newstack(tp))
goto err;
+ lock(&parent->m);
+
tp->ppid = parent->pid;
tp->entry = parent->entry;
@@ -387,6 +389,8 @@ clone(Task *parent)
if (tp->fds)
incref(&parent->fds->ref);
+ unlock(&parent->m);
+
return tp;
err:
@@ -415,7 +419,6 @@ rfork(int flags)
fds = NULL;
data = NULL;
- lock(&proc->m);
if ((flags & RFPROC) != 0) {
if ((tp = clone(proc)) == NULL)
return -1;
@@ -426,6 +429,8 @@ rfork(int flags)
if (savectx(tp) == 0)
return 0;
}
+
+ lock(&proc->m);
if ((flags & RFCNAMEG) != 0) {
if ((ns = newspace(NULL)) == NULL)
goto err;