[CRIU] [PATCH] mm: mark VM_IO and VM_PFNMAP VMA-s as unsupported

Andrey Vagin avagin at openvz.org
Mon May 19 12:02:05 PDT 2014


vmsplice doesn't work for such VMA-s.

This flags is set in a kernel function remap_pfn_range()
(remap kernel memory to userspace), which is widely used by device
drivers to provide direct access to a device memory.

Reported-by: J F <jgmb45 at gmail.com>
Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 include/image.h |  2 ++
 proc_parse.c    | 10 ++++++++++
 2 files changed, 12 insertions(+)

diff --git a/include/image.h b/include/image.h
index dc9b1d5..d95eaa9 100644
--- a/include/image.h
+++ b/include/image.h
@@ -52,6 +52,8 @@
 #define VMA_AREA_SYSVIPC	(1 <<  10)
 #define VMA_AREA_SOCKET		(1 <<  11)
 
+#define VMA_UNSUPP		(1 <<  12)	/* Unsupported VMA */
+
 #define CR_CAP_SIZE	2
 
 #define TASK_COMM_LEN 16
diff --git a/proc_parse.c b/proc_parse.c
index 340ef7d..d0a1bfa 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -137,6 +137,10 @@ static int parse_vmflags(char *buf, struct vma_area *vma_area)
 		else if (_vmflag_match(tok, "nh"))
 			vma_area->e->madv |= (1ul << MADV_NOHUGEPAGE);
 
+		/* vmsplice doesn't work for VM_IO and VM_PFNMAP mappings. */
+		if (_vmflag_match(tok, "io") || _vmflag_match(tok, "pf"))
+			vma_area->e->status |= VMA_UNSUPP;
+
 		/*
 		 * Anything else is just ignored.
 		 */
@@ -326,6 +330,12 @@ int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list, bool use_map_file
 		}
 
 		if (vma_area) {
+			if (vma_area->e->status & VMA_UNSUPP) {
+				pr_err("Unsupported mapping found %016"PRIx64"-%016"PRIx64"\n",
+							vma_area->e->start, vma_area->e->end);
+				goto err;
+			}
+
 			/* Add a guard page only if here is enough space for it */
 			if ((vma_area->e->flags & MAP_GROWSDOWN) &&
 			    prev_end < vma_area->e->start)
-- 
1.8.5.3



More information about the CRIU mailing list