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

Submitted by Kirill Tkhai on Feb. 3, 2017, 4:16 p.m.

Details

Message ID 148613856351.3612.4677356797620654769.stgit@localhost.localdomain
State New
Series "Nested user namespaces support"
Headers show

Commit Message

Kirill Tkhai Feb. 3, 2017, 4:16 p.m.
Restore task's user_ns, and keep in mind we born in parent's user_ns

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

Patch hide | download patch | download mbox

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;