[CRIU] [PATCH 2/2] mount: allow overmount on parent with shared group

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Fri Oct 20 10:24:28 MSK 2017


In CT, we do:

mkdir -p /a/b/c1
mkdir -p /c2
mount --bind /c2 /a/b/c1
mount --rbind /a/b /a

And after that container is not dumpable with error:

mnt: Unable to handle mounts under 146:./a

Just because overmounts with shared parent group are prohibited,
but I can't see any problem with enabling them.

https://jira.sw.ru/browse/PSBM-69501
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 criu/mount.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/criu/mount.c b/criu/mount.c
index f2487fcfb..a20b9613b 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -689,7 +689,7 @@ static int validate_mounts(struct mount_info *info, bool for_dump)
 			return -1;
 
 		if (mnt_is_external(m))
-			goto skip_fstype;
+			continue;
 
 		/*
 		 * Mountpoint can point to / of an FS. In that case this FS
@@ -739,13 +739,6 @@ static int validate_mounts(struct mount_info *info, bool for_dump)
 				}
 			}
 		}
-skip_fstype:
-		if (does_mnt_overmount(m) &&
-		    !list_empty(&m->parent->mnt_share)) {
-			pr_err("Unable to handle mounts under %d:%s\n",
-					m->mnt_id, m->mountpoint);
-			return -1;
-		}
 	}
 
 	return 0;
@@ -1686,12 +1679,21 @@ static int propagate_mount(struct mount_info *mi)
 		char path[PATH_MAX], *mp;
 		bool found = false;
 
+		/*
+		 * If a mount from parent's shared group is not yet mounted
+		 * it shouldn't have 'sibling' in it - see can_mount_now()
+		 */
+		if (!t->mounted)
+			continue;
+
 		mp = mnt_get_sibling_path(mi, t, path, sizeof(path));
 		if (mp == NULL)
 			continue;
 
 		list_for_each_entry(c, &t->children, siblings) {
 			if (mounts_equal(mi, c) && !strcmp(mp, c->mountpoint)) {
+				/* Should not propagate the same mount twice */
+				BUG_ON(c->mounted);
 				pr_debug("\t\tPropagate %s\n", c->mountpoint);
 
 				/*
@@ -2288,7 +2290,7 @@ static int try_remap_mount(struct mount_info *m)
 	if (!does_mnt_overmount(m))
 		return 0;
 
-	BUG_ON(!m->parent || !list_empty(&m->parent->mnt_share));
+	BUG_ON(!m->parent);
 
 	r = xmalloc(sizeof(struct mnt_remap_entry));
 	if (!r)
-- 
2.13.5



More information about the CRIU mailing list