Commit f7b966b4 authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Andrei Vagin

vdso: separate vdso_parse_maps() from vdso_fill_self_symtable()

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.

travis-ci: success for Rectify 32-bit compatible C/R on x86
Signed-off-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 3cd00d04
...@@ -222,15 +222,15 @@ err: ...@@ -222,15 +222,15 @@ err:
return exit_code; 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]; char buf[512];
int ret, exit_code = -1;
FILE *maps; FILE *maps;
*s = (struct vdso_symtable)VDSO_SYMTABLE_INIT; *s = (struct vdso_symtable)VDSO_SYMTABLE_INIT;
maps = fopen_proc(PROC_SELF, "maps"); maps = fopen_proc(pid, "maps");
if (!maps) if (!maps)
return -1; return -1;
...@@ -247,8 +247,7 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s) ...@@ -247,8 +247,7 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s)
if (!has_vdso && !has_vvar) if (!has_vdso && !has_vvar)
continue; continue;
ret = sscanf(buf, "%lx-%lx", &start, &end); if (sscanf(buf, "%lx-%lx", &start, &end) != 2) {
if (ret != 2) {
pr_err("Can't find vDSO/VVAR bounds\n"); pr_err("Can't find vDSO/VVAR bounds\n");
goto err; goto err;
} }
...@@ -260,10 +259,6 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s) ...@@ -260,10 +259,6 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s)
} }
s->vma_start = start; s->vma_start = start;
s->vma_end = end; s->vma_end = end;
ret = vdso_fill_symtable(start, end - start, s);
if (ret)
goto err;
} else { } else {
if (s->vvar_start != VVAR_BAD_ADDR) { if (s->vvar_start != VVAR_BAD_ADDR) {
pr_err("Got second VVAR entry\n"); pr_err("Got second VVAR entry\n");
...@@ -274,6 +269,21 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s) ...@@ -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 * Validate its structure -- for new vDSO format the
* structure must be like * structure must be like
...@@ -292,22 +302,19 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s) ...@@ -292,22 +302,19 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s)
if (s->vma_end != s->vvar_start && if (s->vma_end != s->vvar_start &&
s->vvar_end != s->vma_start) { s->vvar_end != s->vma_start) {
pr_err("Unexpected rt vDSO area bounds\n"); pr_err("Unexpected rt vDSO area bounds\n");
goto err; return -1;
} }
} }
} else { } else {
pr_err("Can't find rt vDSO\n"); pr_err("Can't find rt vDSO\n");
goto err; return -1;
} }
pr_debug("rt [vdso] %lx-%lx [vvar] %lx-%lx\n", pr_debug("rt [vdso] %lx-%lx [vvar] %lx-%lx\n",
s->vma_start, s->vma_end, s->vma_start, s->vma_end,
s->vvar_start, s->vvar_end); s->vvar_start, s->vvar_end);
exit_code = 0; return 0;
err:
fclose(maps);
return exit_code;
} }
int vdso_init(void) int vdso_init(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment