Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

src: Set initproc inside start_init()



details:   https://anonhg.NetBSD.org/src/rev/e64d84e65b56
branches:  trunk
changeset: 318236:e64d84e65b56
user:      kamil <kamil%NetBSD.org@localhost>
date:      Mon Apr 16 14:18:16 2018 +0000
description:
Set initproc inside start_init()

This allows us to stop using the rnewprocp argument in fork1(9).

The rnewprocp argument will be removed soon from the API, as it can cause
use-after-free scenarios.

No functional change intended.

Noted by <Mateusz Guzik>
Reference: http://mail-index.netbsd.org/tech-kern/2017/09/08/msg022267.html

Sponsored by <The NetBSD Foundation>

diffstat:

 sys/kern/init_main.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (36 lines):

diff -r 4aaeb3f66dc4 -r e64d84e65b56 sys/kern/init_main.c
--- a/sys/kern/init_main.c      Mon Apr 16 13:12:35 2018 +0000
+++ b/sys/kern/init_main.c      Mon Apr 16 14:18:16 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init_main.c,v 1.495 2018/02/04 17:31:51 maxv Exp $     */
+/*     $NetBSD: init_main.c,v 1.496 2018/04/16 14:18:16 kamil Exp $    */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.495 2018/02/04 17:31:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.496 2018/04/16 14:18:16 kamil Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -608,7 +608,7 @@
         * wait for us to inform it that the root file system has been
         * mounted.
         */
-       if (fork1(l, 0, SIGCHLD, NULL, 0, start_init, NULL, NULL, &initproc))
+       if (fork1(l, 0, SIGCHLD, NULL, 0, start_init, NULL, NULL, NULL))
                panic("fork init");
 
        /*
@@ -930,6 +930,8 @@
        char ipath[129];
        int ipx, len;
 
+       initproc = p;
+
        /*
         * Now in process 1.
         */



Home | Main Index | Thread Index | Old Index