[CRIU] [PATCH v2 30/36] ns: Set target user_ns after create_children_and_session()

Kirill Tkhai ktkhai at virtuozzo.com
Fri Feb 3 08:16:03 PST 2017


Restore task's user_ns, and keep in mind we born in parent's user_ns

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/cr-restore.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 07a966154..96e554338 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -991,6 +991,11 @@ static inline int fork_with_pid(struct pstree_item *item)
 	pid_t pid = item->pid->ns[0].virt;
 	bool locked;
 
+	if (item != root_item)
+		item->user_ns = current->user_ns;
+	else
+		item->user_ns = root_user_ns;
+
 	if (item->pid->state != TASK_HELPER) {
 		if (open_core(pid, &ca.core))
 			return -1;
@@ -1431,6 +1436,8 @@ static int restore_task_with_children(void *_arg)
 	if (create_children_and_session())
 		goto err;
 
+	if (current->ids && set_user_ns(current->ids->user_ns_id) < 0)
+		goto err;
 
 	if (unmap_guard_pages(current))
 		goto err;



More information about the CRIU mailing list