[CRIU] [PATCH] mount: don't rewrite root for external mounts

Andrey Vagin avagin at openvz.org
Fri Dec 4 06:05:56 PST 2015


From: Andrew Vagin <avagin at virtuozzo.com>

It's used to restore bind-mounts. For example, we cat the common
part of bind-mounts:

Core was generated by `criu restore -vvvv --file-locks --tcp-established --evasive-devices --manage-cg'.
Program terminated with signal 11, Segmentation fault.
741                     BUG_ON(target_root[tok] == '\0');
(gdb) bt

https://jira.sw.ru/browse/PSBM-41932

Reported-by: Virtuozzo QA Team
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 mount.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/mount.c b/mount.c
index ca10d43..b7b2af5 100644
--- a/mount.c
+++ b/mount.c
@@ -2026,7 +2026,7 @@ static int do_bind_mount(struct mount_info *mi)
 			 * is tuned in collect_mnt_from_image to refer
 			 * to proper location in the namespace we restore.
 			 */
-			root = mi->root;
+			root = mi->external->val;
 			force_private_remount = mi->internal_sharing;
 			goto do_bind;
 		}
@@ -2368,13 +2368,12 @@ static int get_mp_root(MntEntry *me, struct mount_info *mi)
 {
 	struct ext_mount *em = NULL;
 
-	if (!me->ext_mount) {
-		mi->root = xstrdup(me->root);
-		if (!mi->root)
-			return -1;
+	mi->root = xstrdup(me->root);
+	if (!mi->root)
+		return -1;
 
+	if (!me->ext_mount)
 		goto out;
-	}
 
 	/*
 	 * External mount point -- get the reverse mapping
@@ -2407,10 +2406,9 @@ static int get_mp_root(MntEntry *me, struct mount_info *mi)
 	}
 
 	mi->external = em;
-	mi->root = em->val;
 out:
 	pr_debug("\t\tWill mount %d from %s%s\n",
-			mi->mnt_id, mi->root, em ? " (E)" : "");
+			mi->mnt_id, em ? em->val : mi->root, em ? " (E)" : "");
 	return 0;
 }
 
-- 
2.4.3



More information about the CRIU mailing list