[CRIU] [PATCH] zdtm: add a new test case for checking vma-s with the MAP_GROWSDOWN flags

Andrey Vagin avagin at openvz.org
Fri Aug 9 06:21:24 EDT 2013


Here are two case:
* check that a vma grows after restoring
* check that a vma can be restored if its guard page was overlapped by
  another vma.

Currently criu isn't able to dump/restore this test case. Who wants to
fix this issue?

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/zdtm/live/static/Makefile   |  1 +
 test/zdtm/live/static/grow_map.c | 66 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+)
 create mode 100644 test/zdtm/live/static/grow_map.c

diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index 48d47c0..9c2c581 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -98,6 +98,7 @@ TST_NOFILE	=				\
 		sigaltstack			\
 		sk-netlink			\
 		mem-touch			\
+		grow_map			\
 #		jobctl00			\
 
 TST_FILE	=				\
diff --git a/test/zdtm/live/static/grow_map.c b/test/zdtm/live/static/grow_map.c
new file mode 100644
index 0000000..7ce0eb8
--- /dev/null
+++ b/test/zdtm/live/static/grow_map.c
@@ -0,0 +1,66 @@
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc	= "Check that VMA-s with MAP_GROWSDOWN are restored correctly";
+const char *test_author	= "Andrew Vagin <avagin at openvz.org>";
+
+int main(int argc, char **argv)
+{
+	char *start_addr, *fake_grow_down, *test_addr, *grow_down;
+	test_init(argc, argv);
+
+	start_addr = mmap(NULL, PAGE_SIZE * 10, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+	if (start_addr == MAP_FAILED) {
+		err("Can't mal a new region");
+		return 1;
+	}
+	munmap(start_addr, PAGE_SIZE * 10);
+
+	fake_grow_down = mmap(start_addr + PAGE_SIZE * 5, PAGE_SIZE,
+			 PROT_READ | PROT_WRITE,
+			 MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED | MAP_GROWSDOWN, -1, 0);
+	if (fake_grow_down == MAP_FAILED) {
+		err("Can't mal a new region");
+		return 1;
+	}
+
+	fake_grow_down[0] = 'c';
+	*(fake_grow_down - 1) = 'b';
+
+	/* overlap the guard page of fake_grow_down */
+	test_addr = mmap(start_addr + PAGE_SIZE * 3, PAGE_SIZE,
+			 PROT_READ | PROT_WRITE,
+			 MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0);
+	if (test_addr == MAP_FAILED) {
+		err("Can't mal a new region");
+		return 1;
+	}
+
+	grow_down = mmap(start_addr + PAGE_SIZE * 2, PAGE_SIZE,
+			 PROT_READ | PROT_WRITE,
+			 MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED | MAP_GROWSDOWN, -1, 0);
+	if (grow_down == MAP_FAILED) {
+		err("Can't mal a new region");
+		return 1;
+	}
+
+	test_daemon();
+	test_waitsig();
+
+	munmap(test_addr, PAGE_SIZE);
+	if (fake_grow_down[0] != 'c' || *(fake_grow_down - 1) != 'b') {
+		fail("%c %c\n", fake_grow_down[0], *(fake_grow_down - 1));
+		return 1;
+	}
+
+	grow_down[0] = 'z';
+	*(grow_down - 1) = 'x';
+
+	pass();
+
+	return 0;
+}
-- 
1.8.3.1



More information about the CRIU mailing list