Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Change the place of initproc initialization



details:   https://anonhg.NetBSD.org/src/rev/022b791207d9
branches:  trunk
changeset: 838597:022b791207d9
user:      kamil <kamil%NetBSD.org@localhost>
date:      Wed Jan 23 13:38:30 2019 +0000

description:
Change the place of initproc initialization

The initproc variable cannot be initialized in start_init as there
is a race between vfs_mountroot and start_init.

PR kern/53817 by Andreas Gustafsson

diffstat:

 sys/kern/init_main.c |  14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (42 lines):

diff -r cbba1ffe2b32 -r 022b791207d9 sys/kern/init_main.c
--- a/sys/kern/init_main.c      Wed Jan 23 11:15:11 2019 +0000
+++ b/sys/kern/init_main.c      Wed Jan 23 13:38:30 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init_main.c,v 1.501 2018/12/26 22:16:26 thorpej Exp $  */
+/*     $NetBSD: init_main.c,v 1.502 2019/01/23 13:38:30 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.501 2018/12/26 22:16:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.502 2019/01/23 13:38:30 kamil Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -617,6 +617,14 @@
                panic("fork init");
 
        /*
+        * The initproc variable cannot be initialized in start_init as there
+        * is a race between vfs_mountroot and start_init.
+        */
+       mutex_enter(proc_lock);
+       initproc = proc_find_raw(1);
+       mutex_exit(proc_lock);
+
+       /*
         * Load any remaining builtin modules, and hand back temporary
         * storage to the VM system.  Then require force when loading any
         * remaining un-init'ed built-in modules to avoid later surprises.
@@ -946,8 +954,6 @@
        char ipath[129];
        int ipx, len;
 
-       initproc = p;
-
        /*
         * Now in process 1.
         */



Home | Main Index | Thread Index | Old Index