[CRIU] [PATCHv3 11/23] vdso: separate vdso_parse_maps() from vdso_fill_self_symtable()

Dmitry Safonov dsafonov at virtuozzo.com
Fri Dec 9 10:19:37 PST 2016


We need to know compatible vdso/vvar sizes, so add pid argument
to parse another process - it's needed to fork(), remap vdso
and parse child's vdso/vvar in CRIU.

Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 criu/vdso.c | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/criu/vdso.c b/criu/vdso.c
index dbbf84e09714..47f0ff498adc 100644
--- a/criu/vdso.c
+++ b/criu/vdso.c
@@ -222,15 +222,15 @@ err:
 	return exit_code;
 }
 
-static int vdso_fill_self_symtable(struct vdso_symtable *s)
+static int vdso_parse_maps(pid_t pid, struct vdso_symtable *s)
 {
+	int exit_code = -1;
 	char buf[512];
-	int ret, exit_code = -1;
 	FILE *maps;
 
 	*s = (struct vdso_symtable)VDSO_SYMTABLE_INIT;
 
-	maps = fopen_proc(PROC_SELF, "maps");
+	maps = fopen_proc(pid, "maps");
 	if (!maps)
 		return -1;
 
@@ -247,8 +247,7 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s)
 		if (!has_vdso && !has_vvar)
 			continue;
 
-		ret = sscanf(buf, "%lx-%lx", &start, &end);
-		if (ret != 2) {
+		if (sscanf(buf, "%lx-%lx", &start, &end) != 2) {
 			pr_err("Can't find vDSO/VVAR bounds\n");
 			goto err;
 		}
@@ -260,10 +259,6 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s)
 			}
 			s->vma_start = start;
 			s->vma_end = end;
-
-			ret = vdso_fill_symtable(start, end - start, s);
-			if (ret)
-				goto err;
 		} else {
 			if (s->vvar_start != VVAR_BAD_ADDR) {
 				pr_err("Got second VVAR entry\n");
@@ -274,6 +269,21 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s)
 		}
 	}
 
+	exit_code = 0;
+err:
+	fclose(maps);
+	return exit_code;
+}
+
+static int vdso_fill_self_symtable(struct vdso_symtable *s)
+{
+
+	if (vdso_parse_maps(PROC_SELF, s))
+		return -1;
+
+	if (vdso_fill_symtable(s->vma_start, s->vma_end - s->vma_start, s))
+		return -1;
+
 	/*
 	 * Validate its structure -- for new vDSO format the
 	 * structure must be like
@@ -292,22 +302,19 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s)
 			if (s->vma_end != s->vvar_start &&
 			    s->vvar_end != s->vma_start) {
 				pr_err("Unexpected rt vDSO area bounds\n");
-				goto err;
+				return -1;
 			}
 		}
 	} else {
 		pr_err("Can't find rt vDSO\n");
-		goto err;
+		return -1;
 	}
 
 	pr_debug("rt [vdso] %lx-%lx [vvar] %lx-%lx\n",
 		 s->vma_start, s->vma_end,
 		 s->vvar_start, s->vvar_end);
 
-	exit_code = 0;
-err:
-	fclose(maps);
-	return exit_code;
+	return 0;
 }
 
 int vdso_init(void)
-- 
2.10.2



More information about the CRIU mailing list