Module Name:    src
Committed By:   kamil
Date:           Mon Apr 16 14:18:16 UTC 2018

Modified Files:
        src/sys/kern: init_main.c

Log Message:
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>


To generate a diff of this commit:
cvs rdiff -u -r1.495 -r1.496 src/sys/kern/init_main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/init_main.c
diff -u src/sys/kern/init_main.c:1.495 src/sys/kern/init_main.c:1.496
--- src/sys/kern/init_main.c:1.495	Sun Feb  4 17:31:51 2018
+++ src/sys/kern/init_main.c	Mon Apr 16 14:18:16 2018
@@ -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 @@ main(void)
 	 * 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 @@ start_init(void *arg)
 	char ipath[129];
 	int ipx, len;
 
+	initproc = p;
+
 	/*
 	 * Now in process 1.
 	 */

Reply via email to