From owner-svn-src-head@freebsd.org Thu Jul 5 16:16:29 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EFD711038E71; Thu, 5 Jul 2018 16:16:28 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9E63485769; Thu, 5 Jul 2018 16:16:28 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7F7981C3D9; Thu, 5 Jul 2018 16:16:28 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w65GGSGE033863; Thu, 5 Jul 2018 16:16:28 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w65GGSfk033862; Thu, 5 Jul 2018 16:16:28 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201807051616.w65GGSfk033862@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Thu, 5 Jul 2018 16:16:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335993 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: bz X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 335993 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jul 2018 16:16:29 -0000 Author: bz Date: Thu Jul 5 16:16:28 2018 New Revision: 335993 URL: https://svnweb.freebsd.org/changeset/base/335993 Log: With the introduction of reapers and reaplists in r275800, proc0 and init are setup as a circular dependency. create_init() calls fork1() which calls do_fork(). There the newproc (initproc) is setup with a reaper of proc0 who's reaper points to itself. The newproc (initproc) is then put on its reaper's (proc0) p_reaplist (initproc is a descendants of proc0 for proc0 to reap). Upon return to create_init(), proc0 is added to initproc's p_reaplist (which would mean proc0 is a descendant of init, for init to reap). This creates a circular dependency which eventually leads to LIST corruptions when trying to kill init and a proc0. For the base system we never really hit this case during reboot. The problem only became visible after adding more virtual process spaces which could go away cleanly (work existing in an experimental branch). Reviewed by: kib Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D15924 Modified: head/sys/kern/init_main.c Modified: head/sys/kern/init_main.c ============================================================================== --- head/sys/kern/init_main.c Thu Jul 5 16:15:17 2018 (r335992) +++ head/sys/kern/init_main.c Thu Jul 5 16:16:28 2018 (r335993) @@ -514,6 +514,7 @@ proc0_init(void *dummy __unused) p->p_peers = 0; p->p_leader = p; p->p_reaper = p; + p->p_treeflag |= P_TREE_REAPER; LIST_INIT(&p->p_reaplist); strncpy(p->p_comm, "kernel", sizeof (p->p_comm)); @@ -851,7 +852,6 @@ create_init(const void *udata __unused) PROC_LOCK(initproc); initproc->p_flag |= P_SYSTEM | P_INMEM; initproc->p_treeflag |= P_TREE_REAPER; - LIST_INSERT_HEAD(&initproc->p_reaplist, &proc0, p_reapsibling); oldcred = initproc->p_ucred; crcopy(newcred, oldcred); #ifdef MAC