[CRIU] [PATCH 2/9] zdtm: add a test for unsupported children collision

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Tue Jul 10 19:02:24 MSK 2018


These test is not automatic as after kernel v4.11 behaviour changes, on
older kernel we get children collision:

817 188 0:48 / /zdtm/static/unsupported_children_collision.test/share1 rw,relatime shared:942 - tmpfs share rw
> 818 817 0:124 / /zdtm/static/unsupported_children_collision.test/share1/child rw,relatime shared:943 - tmpfs child1 rw
819 188 0:48 / /zdtm/static/unsupported_children_collision.test/share2 rw,relatime shared:942 - tmpfs share rw
820 819 0:125 / /zdtm/static/unsupported_children_collision.test/share2/child rw,relatime shared:944 - tmpfs child2 rw
> 821 817 0:125 / /zdtm/static/unsupported_children_collision.test/share1/child rw,relatime shared:944 - tmpfs child2 rw

Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 test/zdtm/static/Makefile                     |   1 +
 .../static/unsupported_children_collision.c   | 110 ++++++++++++++++++
 .../unsupported_children_collision.desc       |   1 +
 3 files changed, 112 insertions(+)
 create mode 100644 test/zdtm/static/unsupported_children_collision.c
 create mode 100644 test/zdtm/static/unsupported_children_collision.desc

diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index d61ef33b9..787801cf9 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -345,6 +345,7 @@ TST_DIR		=				\
 		del_standalone_un		\
 		sk-unix-mntns			\
 		sk-unix01			\
+		unsupported_children_collision  \
 
 TST_DIR_FILE	=				\
 		chroot				\
diff --git a/test/zdtm/static/unsupported_children_collision.c b/test/zdtm/static/unsupported_children_collision.c
new file mode 100644
index 000000000..15e8f3ba0
--- /dev/null
+++ b/test/zdtm/static/unsupported_children_collision.c
@@ -0,0 +1,110 @@
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <limits.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc	= "Check unsupported children collision for mounts";
+const char *test_author	= "Pavel Tikhomirov <ptikhomirov at virtuozzo.com>";
+
+char *dirname;
+TEST_OPTION(dirname, string, "directory name", 1);
+
+int main(int argc, char **argv)
+{
+	char share1[PATH_MAX], share2[PATH_MAX];
+	char child1[PATH_MAX], child2[PATH_MAX];
+
+	test_init(argc, argv);
+
+	if (mkdir(dirname, 0700)) {
+		pr_perror("mkdir");
+		return 1;
+	}
+
+	if (mount("zdtm_fs", dirname, "tmpfs", 0, NULL)) {
+		pr_perror("mount");
+		return 1;
+	}
+
+	if (mount(NULL, dirname, NULL, MS_PRIVATE, NULL)) {
+		pr_perror("mount");
+		return 1;
+	}
+
+	snprintf(share1, sizeof(share1), "%s/share1", dirname);
+	if (mkdir(share1, 0700)) {
+		pr_perror("mkdir");
+		return 1;
+	}
+
+	if (mount("share", share1, "tmpfs", 0, NULL)) {
+		pr_perror("mount");
+		return 1;
+	}
+
+	if (mount(NULL, share1, NULL, MS_SHARED, NULL)) {
+		pr_perror("mount");
+		return 1;
+	}
+
+	snprintf(child1, sizeof(child1), "%s/share1/child", dirname);
+	if (mkdir(child1, 0700)) {
+		pr_perror("mkdir");
+		return 1;
+	}
+
+	if (mount("child1", child1, "tmpfs", 0, NULL)) {
+		pr_perror("mount");
+		return 1;
+	}
+
+	snprintf(share2, sizeof(share2), "%s/share2", dirname);
+	if (mkdir(share2, 0700)) {
+		pr_perror("mkdir");
+		return 1;
+	}
+
+	if (mount(share1, share2, NULL, MS_BIND, NULL)) {
+		pr_perror("mount");
+		return 1;
+	}
+
+	snprintf(child2, sizeof(child2), "%s/share2/child", dirname);
+	if (mount("child2", child2, "tmpfs", 0, NULL)) {
+		pr_perror("mount");
+		return 1;
+	}
+
+	test_daemon();
+	test_waitsig();
+
+	if (umount(child2)) {
+		pr_perror("Unable to umount %s", share1);
+		return 1;
+	}
+
+	if (umount(share2)) {
+		pr_perror("Unable to umount %s", share2);
+		return 1;
+	}
+
+	if (umount(child1)) {
+		pr_perror("Unable to umount %s", child1);
+		return 1;
+	}
+
+	if (umount(share1)) {
+		pr_perror("Unable to umount %s", share1);
+		return 1;
+	}
+
+	if (umount(dirname)) {
+		pr_perror("Unable to umount %s", dirname);
+		return 1;
+	}
+
+	pass();
+
+	return 0;
+}
diff --git a/test/zdtm/static/unsupported_children_collision.desc b/test/zdtm/static/unsupported_children_collision.desc
new file mode 100644
index 000000000..6da6e749f
--- /dev/null
+++ b/test/zdtm/static/unsupported_children_collision.desc
@@ -0,0 +1 @@
+{'flavor': 'ns uns', 'flags': 'suid noauto crfail'}
-- 
2.17.0



More information about the CRIU mailing list