2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00

auxv: Use real size of the auxv vector

The size of vector depends on the kernel config
so use the real size of a vector dumped. Otherwise
we might fail on restore.

Reported-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Cyrill Gorcunov
2012-10-29 19:54:12 +04:00
committed by Pavel Emelyanov
parent 84ed00b674
commit b1f1154c8a
4 changed files with 8 additions and 6 deletions

View File

@@ -537,7 +537,7 @@ static int dump_task_creds(struct parasite_ctl *ctl, const struct cr_fdset *fds)
#define assign_reg(dst, src, e) do { dst->e = (__typeof__(dst->e))src.e; } while (0)
#define assign_array(dst, src, e) memcpy(dst->e, &src.e, sizeof(src.e))
static int get_task_auxv(pid_t pid, MmEntry *mm)
static int get_task_auxv(pid_t pid, MmEntry *mm, size_t *size)
{
int fd, ret, i;
@@ -560,6 +560,7 @@ static int get_task_auxv(pid_t pid, MmEntry *mm)
}
}
*size = i;
ret = 0;
err:
close_safe(&fd);
@@ -591,7 +592,7 @@ static int dump_task_mm(pid_t pid, const struct proc_pid_stat *stat,
if (!mme.mm_saved_auxv)
goto out;
if (get_task_auxv(pid, &mme))
if (get_task_auxv(pid, &mme, &mme.n_mm_saved_auxv))
goto out;
pr_info("OK\n");

View File

@@ -1208,13 +1208,14 @@ static int prepare_mm(pid_t pid, struct task_restore_core_args *args)
args->mm.n_mm_saved_auxv = 0;
args->mm.mm_saved_auxv = NULL;
if (mm->n_mm_saved_auxv != AT_VECTOR_SIZE) {
if (mm->n_mm_saved_auxv > AT_VECTOR_SIZE) {
pr_err("Image corrupted on pid %d\n", pid);
goto out;
}
args->mm_saved_auxv_size = pb_repeated_size(mm, mm_saved_auxv);
memcpy(args->mm_saved_auxv, mm->mm_saved_auxv,
pb_repeated_size(mm, mm_saved_auxv));
args->mm_saved_auxv_size);
exe_fd = open_reg_by_id(args->mm.exe_file_id);
if (exe_fd < 0)

View File

@@ -110,6 +110,7 @@ struct task_restore_core_args {
MmEntry mm;
u64 mm_saved_auxv[AT_VECTOR_SIZE];
u32 mm_saved_auxv_size;
u64 blk_sigset;
char comm[TASK_COMM_LEN];
TaskKobjIdsEntry ids;

View File

@@ -467,8 +467,7 @@ long __export_restore_task(struct task_restore_core_args *args)
ret |= sys_prctl_safe(PR_SET_MM, PR_SET_MM_ARG_END, (long)args->mm.mm_arg_end, 0);
ret |= sys_prctl_safe(PR_SET_MM, PR_SET_MM_ENV_START, (long)args->mm.mm_env_start, 0);
ret |= sys_prctl_safe(PR_SET_MM, PR_SET_MM_ENV_END, (long)args->mm.mm_env_end, 0);
ret |= sys_prctl_safe(PR_SET_MM, PR_SET_MM_AUXV, (long)args->mm_saved_auxv,
sizeof(args->mm_saved_auxv));
ret |= sys_prctl_safe(PR_SET_MM, PR_SET_MM_AUXV, (long)args->mm_saved_auxv, args->mm_saved_auxv_size);
if (ret)
goto core_restore_end;