[CRIU] [PATCH 02/11] namespaces: take into account USERNS id

Andrey Vagin avagin at openvz.org
Wed Aug 13 00:51:29 PDT 2014


and return an error, if a proccess live in another userns,
because criu doesn't support it.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 include/syscall-types.h |  6 +++++-
 namespaces.c            | 18 ++++++++++++++++++
 protobuf/core.proto     |  1 +
 pstree.c                |  2 ++
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/include/syscall-types.h b/include/syscall-types.h
index bab3dba..eb270b3 100644
--- a/include/syscall-types.h
+++ b/include/syscall-types.h
@@ -57,7 +57,11 @@ struct itimerspec;
 #define CLONE_NEWNET	0x40000000
 #endif
 
-#define CLONE_ALLNS	(CLONE_NEWPID | CLONE_NEWNET | CLONE_NEWIPC | CLONE_NEWUTS | CLONE_NEWNS)
+#ifndef CLONE_NEWUSER
+#define CLONE_NEWUSER	0x10000000
+#endif
+
+#define CLONE_ALLNS	(CLONE_NEWPID | CLONE_NEWNET | CLONE_NEWIPC | CLONE_NEWUTS | CLONE_NEWNS | CLONE_NEWUSER)
 
 /* Nested namespaces are supported only for these types */
 #define CLONE_SUBNS	(CLONE_NEWNS)
diff --git a/namespaces.c b/namespaces.c
index 6be030f..538bbda 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -391,6 +391,13 @@ int dump_task_ns_ids(struct pstree_item *item)
 		return -1;
 	}
 
+	ids->has_user_ns_id = true;
+	ids->user_ns_id = get_ns_id(pid, &user_ns_desc);
+	if (!ids->user_ns_id) {
+		pr_err("Can't make userns id\n");
+		return -1;
+	}
+
 	return 0;
 }
 
@@ -422,6 +429,12 @@ int gen_predump_ns_mask(void)
 	return 0;
 }
 
+static int dump_user_ns(pid_t pid, int ns_id)
+{
+	pr_err("User namesapces are not supported yet\n");
+	return -1;
+}
+
 static int do_dump_namespaces(struct ns_id *ns)
 {
 	int ret = -1;
@@ -446,6 +459,11 @@ static int do_dump_namespaces(struct ns_id *ns)
 				ns->id, ns->pid);
 		ret = dump_net_ns(ns->pid, ns->id);
 		break;
+	case CLONE_NEWUSER:
+		pr_info("Dump USER namespace info %d via %d\n",
+				ns->id, ns->pid);
+		ret = dump_user_ns(ns->pid, ns->id);
+		break;
 	default:
 		pr_err("Unknown namespace flag %x", ns->nd->cflag);
 		break;
diff --git a/protobuf/core.proto b/protobuf/core.proto
index d850e2e..8810376 100644
--- a/protobuf/core.proto
+++ b/protobuf/core.proto
@@ -32,6 +32,7 @@ message task_kobj_ids_entry {
 	optional uint32			ipc_ns_id	= 7;
 	optional uint32			uts_ns_id	= 8;
 	optional uint32			mnt_ns_id	= 9;
+	optional uint32			user_ns_id	= 10;
 }
 
 message thread_sas_entry {
diff --git a/pstree.c b/pstree.c
index d005b64..c905317 100644
--- a/pstree.c
+++ b/pstree.c
@@ -603,6 +603,8 @@ static unsigned long get_clone_mask(TaskKobjIdsEntry *i,
 		mask |= CLONE_NEWUTS;
 	if (i->mnt_ns_id != p->mnt_ns_id)
 		mask |= CLONE_NEWNS;
+	if (i->user_ns_id != p->user_ns_id)
+		mask |= CLONE_NEWUSER;
 
 	return mask;
 }
-- 
1.9.3



More information about the CRIU mailing list