[CRIU] [PATCH 14/15] fault-injection: Add FI_HUGE_ANON_SHMEM_ID type

Cyrill Gorcunov gorcunov at openvz.org
Wed Oct 25 11:39:39 MSK 2017


To test if we can survive with shmid more than 4 bytes
long in image formats.

Without the fix for shmid

 | [root at uranus criu] test/zdtm.py run -t zdtm/static/maps01 --fault 132 -f h -k always
 | === Run 1/1 ================ zdtm/static/maps01
 |
 | ========================= Run zdtm/static/maps01 in h ==========================
 | Start test
 | Test is SUID
 | ./maps01 --pidfile=maps01.pid --outfile=maps01.out
 | Run criu dump
 | Forcing 132 fault
 | Run criu restore
 | Forcing 132 fault
 | =[log]=> dump/zdtm/static/maps01/36/1/restore.log
 | ------------------------ grep Error ------------------------
 | (00.016464)     37: Opening 0x007f39c04b5000-0x007f3a004b5000 0000000000000000 (101) vma
 | (00.016465)     37: Search for 0x007f39c04b5000 shmem 0x10118e915 0x7f97f7ae4ae8/36
 | (00.016470)     37: Waiting for the 10118e915 shmem to appear
 | (00.016479)     36: No pagemap-shmem-18409749.img image
 | (00.016481)     36: Error (criu/shmem.c:559): Can't restore shmem content
 | (00.016501)     36: Error (criu/mem.c:1208): `- Can't open vma
 | (00.016552) Error (criu/cr-restore.c:2449): Restoring FAILED.
 | ------------------------ ERROR OVER ------------------------

And with the fix

 | [root at uranus criu] test/zdtm.py run -t zdtm/static/maps01 --fault 132 -f h -k always
 | === Run 1/1 ================ zdtm/static/maps01
 |
 | ========================= Run zdtm/static/maps01 in h ==========================
 | Start test
 | Test is SUID
 | ./maps01 --pidfile=maps01.pid --outfile=maps01.out
 | Run criu dump
 | Forcing 132 fault
 | Run criu restore
 | Forcing 132 fault
 | Send the 15 signal to  36
 | Wait for zdtm/static/maps01(36) to die for 0.100000
 | ========================= Test zdtm/static/maps01 PASS =========================

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 criu/include/fault-injection.h |  3 +++
 criu/proc_parse.c              | 10 +++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/criu/include/fault-injection.h b/criu/include/fault-injection.h
index 0da6bf8731c3..d6ea11763f97 100644
--- a/criu/include/fault-injection.h
+++ b/criu/include/fault-injection.h
@@ -17,6 +17,7 @@ enum faults {
 	FI_NO_MEMFD = 129,
 	FI_NO_BREAKPOINTS = 130,
 	FI_PARTIAL_PAGES = 131,
+	FI_HUGE_ANON_SHMEM_ID = 132,
 	FI_MAX,
 };
 
@@ -33,6 +34,8 @@ static inline bool __fault_injected(enum faults f, enum faults fi_strategy)
 	return fi_strategy == f;
 }
 
+#define FI_HUGE_ANON_SHMEM_ID_BASE	(0xfffffffflu)
+
 #ifndef CR_NOGLIBC
 
 extern enum faults fi_strategy;
diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index a4d6998d8eb1..299649faaa04 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -40,6 +40,7 @@
 #include "cgroup-props.h"
 #include "timerfd.h"
 #include "path.h"
+#include "fault-injection.h"
 
 #include "protobuf.h"
 #include "images/fdinfo.pb-c.h"
@@ -310,8 +311,12 @@ static int vma_get_mapfile_user(const char *fname, struct vma_area *vma,
 		vma->e->status |= VMA_ANON_SHARED;
 		vma->e->shmid = vfi->ino;
 
-		if (!strncmp(fname, "/SYSV", 5))
+		if (!strncmp(fname, "/SYSV", 5)) {
 			vma->e->status |= VMA_AREA_SYSVIPC;
+		} else {
+			if (fault_injected(FI_HUGE_ANON_SHMEM_ID))
+				vma->e->shmid += FI_HUGE_ANON_SHMEM_ID_BASE;
+		}
 
 		return 0;
 	}
@@ -598,6 +603,9 @@ static int handle_vma(pid_t pid, struct vma_area *vma_area,
 			if (!strncmp(file_path, "/SYSV", 5)) {
 				pr_info("path: %s\n", file_path);
 				vma_area->e->status |= VMA_AREA_SYSVIPC;
+			} else {
+				if (fault_injected(FI_HUGE_ANON_SHMEM_ID))
+					vma_area->e->shmid += FI_HUGE_ANON_SHMEM_ID_BASE;
 			}
 		} else {
 			if (vma_area->e->flags & MAP_PRIVATE)
-- 
2.7.5



More information about the CRIU mailing list