[CRIU] [PATCH] restore: Compute auxv size taking into account kernel's mm::saved_auxv type

Pavel Emelyanov xemul at parallels.com
Mon Feb 10 03:22:16 PST 2014


On 02/10/2014 03:15 PM, Cyrill Gorcunov wrote:
> On 32-bit ARM machine we've got:
> 
>  | 10:45:28.595:  4927: new environ: GIT_URL=git://git.criu.org/crtools.git
>  | 10:45:28.595:  4927: FAIL: cmdlinenv00.c:116: auxv corrupted on restore (errno = 11 (Resource temporarily unavailable))
> 
> that's because in commit 459828b6bec92d664bcce8419436e528be2094f2
> we've changed reading procedure of auxv but forgot to update
> restore procedure (which were thinking that size of vector
> remains in number of "passes".

IOW, we broke backward compatibility, right?

> Fix it computing proper number of bytes need to be passed into
> kernel prctl call, same time it allows us to copy auxv to
> needed destination in one memcpy call.
> 
> Reported-by: Andrey Vagin <avagin at openvz.org>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  cr-restore.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/cr-restore.c b/cr-restore.c
> index 22614dba1207..792f08eb6448 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -1920,22 +1920,23 @@ static int prepare_creds(int pid, struct task_restore_args *args)
>  
>  static int prepare_mm(pid_t pid, struct task_restore_args *args)
>  {
> -	int exe_fd, i, ret = -1;
> +	int exe_fd, ret = -1;
>  	MmEntry *mm = current->rst->mm;
> +	size_t size;
>  
>  	args->mm = *mm;
>  	args->mm.n_mm_saved_auxv = 0;
>  	args->mm.mm_saved_auxv = NULL;
>  
> -	if (mm->n_mm_saved_auxv > AT_VECTOR_SIZE) {
> +	size = mm->n_mm_saved_auxv * sizeof(mm->mm_saved_auxv[0]);
> +
> +	if (size / sizeof(long) > AT_VECTOR_SIZE) {
>  		pr_err("Image corrupted on pid %d\n", pid);
>  		goto out;
>  	}
>  
> -	args->mm_saved_auxv_size = mm->n_mm_saved_auxv*sizeof(auxv_t);
> -	for (i = 0; i < mm->n_mm_saved_auxv; ++i) {
> -		args->mm_saved_auxv[i] = (auxv_t)mm->mm_saved_auxv[i];
> -	}
> +	args->mm_saved_auxv_size = size;
> +	memcpy(args->mm_saved_auxv, mm->mm_saved_auxv, size);
>  
>  	exe_fd = open_reg_by_id(mm->exe_file_id);
>  	if (exe_fd < 0)
> 




More information about the CRIU mailing list