[CRIU] [PATCH] zdtm: protect random pages in maps04

Andrey Vagin avagin at openvz.org
Fri Mar 29 12:29:39 EDT 2013


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/zdtm/live/static/maps04.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/test/zdtm/live/static/maps04.c b/test/zdtm/live/static/maps04.c
index 86b23e6..daf841e 100644
--- a/test/zdtm/live/static/maps04.c
+++ b/test/zdtm/live/static/maps04.c
@@ -21,6 +21,7 @@ int main(int argc, char ** argv)
 {
 	void *m;
 	uint32_t crc;
+	int i;
 
 	test_init(argc, argv);
 
@@ -35,9 +36,18 @@ int main(int argc, char ** argv)
 	crc = ~0;
 	datagen(m, MEM_SIZE, &crc);
 
+	for (i = 0; i < MEM_SIZE / (1<<20); i++)
+		if (mprotect(m + (lrand48() * PAGE_SIZE % MEM_SIZE), PAGE_SIZE, PROT_NONE)) {
+			err("mprotect");
+			return 1;
+		}
+
 	test_daemon();
 	test_waitsig();
 
+	if (mprotect(m, MEM_SIZE, PROT_READ))
+		err("mprotect");
+
 	crc = ~0;
 	if (datachk(m, MEM_SIZE, &crc))
 		fail("Mem corrupted");
-- 
1.7.11.7



More information about the CRIU mailing list