[CRIU] [PATCH v2 08/11] pstree: enable sid handling back

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Mon Jun 5 12:23:30 MSK 2017


These checks skip adding helpers and setting ids in case
of nested pid namespaces.

FIXME disable pgid, as it does not work yet

v2: add a comment near the added check for pgid
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 criu/cr-restore.c |  2 --
 criu/pstree.c     | 23 +++++++++++++++++------
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 53df6f0..43b776a 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1474,8 +1474,6 @@ static void restore_sid(void)
 {
 	pid_t sid;
 
-	if (!list_empty(&top_pid_ns->children))
-		return;
 	/*
 	 * SID can only be reset to pid or inherited from parent.
 	 * Thus we restore it right here to let our kids inherit
diff --git a/criu/pstree.c b/criu/pstree.c
index 9262833..9e6df74 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -1059,9 +1059,6 @@ static int prepare_pstree_ids(void)
 	struct pstree_item *item, *helper;
 	pid_t current_pgid = getpgid(getpid());
 
-	if (!list_empty(&top_pid_ns->children))
-		return 0;
-
 	/*
 	 * Some task can be reparented to init. A helper task should be added
 	 * for restoring sid of such tasks. The helper tasks will be exited
@@ -1118,6 +1115,23 @@ static int prepare_pstree_ids(void)
 		}
 	}
 
+	/*
+	 * FIXME
+	 * Skip process group restore preparation in case of nested pidns.
+	 * As pgid restore is not yet reworked, will do it in a next seriess,
+	 * see corresponding if-check in restore_pgid.
+	 *
+	 * Problem here is that to do setpgid(pid, pgid) a) one should be
+	 * in a same thread group with pid or in a same thread group with
+	 * pid's parent; b) one should be in same pid ns (or it's predecessor)
+	 * with pgid. So if we entered pidns, forked again to have parent in
+	 * same pidns and the grouop leader is outside, we can only get the
+	 * right pgid by inheriting it, so same thing as we do with sessions
+	 * should be done.
+	 */
+	if (!list_empty(&top_pid_ns->children))
+		return 0;
+
 	/* Add a process group leader if it is absent  */
 	for_each_pstree_item(item) {
 		struct pid *pid;
@@ -1368,9 +1382,6 @@ bool restore_before_setsid(struct pstree_item *child)
 {
 	int csid = child->born_sid == -1 ? vsid(child) : child->born_sid;
 
-	if (!list_empty(&top_pid_ns->children))
-		return false;
-
 	if (child->parent->born_sid == csid)
 		return true;
 
-- 
2.9.3



More information about the CRIU mailing list