[CRIU] [PATCH] test: don't do MS_REC|MS_PRIVATE for host mounts

Andrei Vagin avagin at openvz.org
Wed Aug 24 12:25:00 PDT 2016


From: Andrei Vagin <avagin at virtuozzo.com>

Here is a race when someone umounted something and this operation
isn't propagated into our namespace.

CRIU                                | Another process
-----------------------------------------------------------------
pivot_root(".", put_root)           |
mount(put_root, MS_REC|MS_PRIVATE)  |
                                    | umount /xxx/yyy
                                    | umount /xxx -> EBUSY
umount(put_root)

We do this to not affect mounts in put_root, but we can mask
these mounts as slave and this will work for us and for external
users.

Reported-by: Mr Travis
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 test/jenkins/_run_ct | 2 +-
 test/zdtm/lib/ns.c   | 2 +-
 test/zdtm_ct.c       | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/jenkins/_run_ct b/test/jenkins/_run_ct
index 0c47c1c..88b5b6c 100755
--- a/test/jenkins/_run_ct
+++ b/test/jenkins/_run_ct
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 set -e
-mount --make-rprivate /
+mount --make-rslave /
 umount -l  /proc
 mount -t proc proc /proc/
 mount -t binfmt_misc none /proc/sys/fs/binfmt_misc/
diff --git a/test/zdtm/lib/ns.c b/test/zdtm/lib/ns.c
index 9b0614a..acf4a31 100644
--- a/test/zdtm/lib/ns.c
+++ b/test/zdtm/lib/ns.c
@@ -84,7 +84,7 @@ static int prepare_mntns(void)
 		return -1;
 	}
 
-	if (mount("./old", "./old", NULL, MS_PRIVATE | MS_REC , NULL)) {
+	if (mount("./old", "./old", NULL, MS_SLAVE | MS_REC , NULL)) {
 		fprintf(stderr, "Can't bind-mount root: %m\n");
 		return -1;
 	}
diff --git a/test/zdtm_ct.c b/test/zdtm_ct.c
index b5ea1d8..bc88dad 100644
--- a/test/zdtm_ct.c
+++ b/test/zdtm_ct.c
@@ -20,8 +20,8 @@ int main(int argc, char **argv)
 		return 1;
 	pid = fork();
 	if (pid == 0) {
-		if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) {
-			fprintf(stderr, "mount(/, S_REC | MS_PRIVATE)): %m");
+		if (mount(NULL, "/", NULL, MS_REC | MS_SLAVE, NULL)) {
+			fprintf(stderr, "mount(/, S_REC | MS_SLAVE)): %m");
 			return 1;
 		}
 		umount2("/proc", MNT_DETACH);
-- 
2.7.4



More information about the CRIU mailing list