[CRIU] [PATCH v2 2/2] zdtm: shared options should not be lost for bind mounts
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Mon Jun 25 17:47:28 MSK 2018
Just setup these mount configuration:
1150 1371 0:169 / /zdtm/static/private_bind_propagation.test rw,relatime shared:920 - tmpfs zdtm_fs rw
1151 1150 0:170 / /zdtm/static/private_bind_propagation.test/share1 rw,relatime shared:921 - tmpfs share rw
1152 1150 0:170 / /zdtm/static/private_bind_propagation.test/share2 rw,relatime shared:921 - tmpfs share rw
1153 1151 0:169 /source /zdtm/static/private_bind_propagation.test/share1/child rw,relatime - tmpfs zdtm_fs rw
1154 1152 0:169 /source /zdtm/static/private_bind_propagation.test/share2/child rw,relatime - tmpfs zdtm_fs rw
And c/r, sharing options are already checked by zdtm by patch 2/3.
v2: fix missprint in snprintf for child2
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
test/zdtm/static/Makefile | 1 +
test/zdtm/static/private_bind_propagation.c | 116 ++++++++++++++++++
.../zdtm/static/private_bind_propagation.desc | 1 +
3 files changed, 118 insertions(+)
create mode 100644 test/zdtm/static/private_bind_propagation.c
create mode 100644 test/zdtm/static/private_bind_propagation.desc
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index d61ef33b9..ce4195a8d 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 \
+ private_bind_propagation \
TST_DIR_FILE = \
chroot \
diff --git a/test/zdtm/static/private_bind_propagation.c b/test/zdtm/static/private_bind_propagation.c
new file mode 100644
index 000000000..ee4adbd2d
--- /dev/null
+++ b/test/zdtm/static/private_bind_propagation.c
@@ -0,0 +1,116 @@
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <limits.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc = "Check sharing options are restored for bindmounted shared group children";
+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], source[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_SHARED, 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(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(source, sizeof(source), "%s/source", dirname);
+ if (mkdir(source, 0700)) {
+ pr_perror("mkdir");
+ return 1;
+ }
+
+ snprintf(child1, sizeof(child1), "%s/share1/child", dirname);
+ snprintf(child2, sizeof(child2), "%s/share2/child", dirname);
+ if (mkdir(child1, 0700)) {
+ pr_perror("mkdir");
+ return 1;
+ }
+
+ if (mount(source, child1, NULL, MS_BIND, NULL)) {
+ pr_perror("mount");
+ return 1;
+ }
+
+ if (mount(NULL, child1, NULL, MS_PRIVATE, NULL)) {
+ pr_perror("mount");
+ return 1;
+ }
+
+ if (mount(NULL, child2, NULL, MS_PRIVATE, NULL)) {
+ pr_perror("mount");
+ return 1;
+ }
+
+ test_daemon();
+ test_waitsig();
+
+ 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(share2)) {
+ pr_perror("Unable to umount %s", share2);
+ return 1;
+ }
+
+ if (umount(dirname)) {
+ pr_perror("Unable to umount %s", dirname);
+ return 1;
+ }
+
+ pass();
+
+ return 0;
+}
diff --git a/test/zdtm/static/private_bind_propagation.desc b/test/zdtm/static/private_bind_propagation.desc
new file mode 100644
index 000000000..7657ba45c
--- /dev/null
+++ b/test/zdtm/static/private_bind_propagation.desc
@@ -0,0 +1 @@
+{'flavor': 'ns uns', 'flags': 'suid'}
--
2.17.0
More information about the CRIU
mailing list