[CRIU] [PATCH 1/4] Quick bug fix for missing fd for move_in_cgroup

gbellack at google.com gbellack at google.com
Thu Aug 7 15:26:11 PDT 2014


From: gbellack <gbellack at google.com>

There is an issue where if the proccess to be killed spawns a child proccess and
moves it in a child cgroup of the one the parent process is in, the cgroup fd
was being closed in the parent process before it forked the child. Then when
move_in_cgroup() is called for the child process, the file descriptor has
already been closed causing a failure for the second call to move_in_cgroup().
Moved the fd close after the fork call.

Change-Id: I6ae88b95c5410a7f56108e28eb3133f113e868d0
Signed-off-by: Garrison Bellack <gbellack at google.com>
---
 cgroup.c     | 1 -
 cr-restore.c | 8 ++++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/cgroup.c b/cgroup.c
index 6a222a8..299c2f4 100644
--- a/cgroup.c
+++ b/cgroup.c
@@ -619,7 +619,6 @@ static int move_in_cgroup(CgSetEntry *se)
 		}
 	}
 
-	close_service_fd(CGROUP_YARD);
 	return 0;
 }
 
diff --git a/cr-restore.c b/cr-restore.c
index 56ff90a..c82cdd8 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1388,6 +1388,14 @@ static int restore_task_with_children(void *_arg)
 	if (create_children_and_session())
 		goto err;
 
+	/*
+	 * This must be done after forking to allow child
+	 * to get the cgroup fd so it can move into the
+	 * correct /tasks file if it is in a different cgroup
+	 * set than its parent
+	 */
+	close_service_fd(CGROUP_YARD);
+
 	if (restore_task_mnt_ns(current))
 		goto err;
 
-- 
2.0.0.526.g5318336



More information about the CRIU mailing list