[CRIU] [PATCH 3/3] mount: wait when mntns will be created to get its root

Andrey Vagin avagin at openvz.org
Thu Nov 12 08:09:05 PST 2015


From: Andrew Vagin <avagin at virtuozzo.com>

Reported-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 mount.c      | 2 ++
 namespaces.c | 1 +
 2 files changed, 3 insertions(+)

diff --git a/mount.c b/mount.c
index 5a5b90a..ad6728e 100644
--- a/mount.c
+++ b/mount.c
@@ -2912,6 +2912,8 @@ set_root:
 
 int mntns_get_root_fd(struct ns_id *mntns)
 {
+	if (mntns->type != NS_ROOT)
+		futex_wait_while_eq(&mntns->ns_created, 0);
 	return __mntns_get_root_fd(mntns->ns_pid);
 }
 
diff --git a/namespaces.c b/namespaces.c
index 1123492..a2293c3 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -268,6 +268,7 @@ static unsigned int generate_ns_id(int pid, unsigned int kid, struct ns_desc *nd
 
 	nsid->type = type;
 	nsid->kid = kid;
+	futex_set(&nsid->ns_created, 1);
 	nsid_add(nsid, nd, ns_next_id++, pid);
 
 found:
-- 
2.4.3



More information about the CRIU mailing list