[v3,28/33] ns: Set target user_ns after net_ns is set

Submitted by Kirill Tkhai on Feb. 16, 2017, 12:10 p.m.

Details

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

Commit Message

Kirill Tkhai Feb. 16, 2017, 12:10 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 |    8 ++++++++
 1 file changed, 8 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index de9086f7c..04a176f1a 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -745,6 +745,9 @@  static int restore_one_alive_task(int pid, CoreEntry *core)
 	if (restore_task_net_ns(current))
 		return -1;
 
+	if (current->ids && set_user_ns(current->ids->user_ns_id) < 0)
+		return -1;
+
 	if (setup_uffd(pid, ta))
 		return -1;
 
@@ -996,6 +999,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;