Handle ENOMEM during fork()
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 6 Nov 2019 18:21:37 +0000 (13:21 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 6 Nov 2019 18:21:37 +0000 (13:21 -0500)
Reported-by: syzbot+638411bd4594d01e2d70@syzkaller.appspotmail.com
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/src/syscall.c

index 43164ec..efda04f 100644 (file)
@@ -895,8 +895,10 @@ static ssize_t sys_fork(env_t* e)
        env_t* env;
 
        ret = proc_alloc(&env, current, PROC_DUP_FGRP);
-       assert(!ret);
-       assert(env != NULL);
+       if (ret < 0) {
+               set_errno(-ret);
+               return -1;
+       }
        proc_set_progname(env, e->progname);
 
        /* Can't really fork if we don't have a current_ctx to fork */