[CRIU] [PATCH v2 2/2] mounts: Skip already bound siblings in propagate_siblings()

Kirill Tkhai ktkhai at virtuozzo.com
Fri Feb 12 06:27:01 PST 2016


This function may be called several times for a mnt_share family.
The second call with a mi, which was not a bind source during the
first call, leads to double dependence:

a <-> b <-> c

1)propagate_siblings(a)

b->bind = a;
c->bind = a;

2)propagate_siblings(b)

c->bind = b;
(a is not set, because its mounted is 1).

So during c's bind mount criu use b's root and refers to a wrong
directory.

The reproduction: mntns_root_bind02 test.

The patch fixes the problem.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 mount.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mount.c b/mount.c
index 05cf6cf..bf07133 100644
--- a/mount.c
+++ b/mount.c
@@ -2118,7 +2118,7 @@ static int propagate_siblings(struct mount_info *mi)
 	 * to inherite shared group or master id
 	 */
 	list_for_each_entry(t, &mi->mnt_share, mnt_share) {
-		if (t->mounted)
+		if (t->mounted || t->bind)
 			continue;
 		pr_debug("\t\tBind share %s\n", t->mountpoint);
 		t->bind = mi;
@@ -2126,7 +2126,7 @@ static int propagate_siblings(struct mount_info *mi)
 	}
 
 	list_for_each_entry(t, &mi->mnt_slave_list, mnt_slave) {
-		if (t->mounted)
+		if (t->mounted || t->bind)
 			continue;
 		pr_debug("\t\tBind slave %s\n", t->mountpoint);
 		t->bind = mi;



More information about the CRIU mailing list