[CRIU] [PATCH 4/4] prctl: restore -- Use new PR_SET_MM_MAP if kernel supports

Pavel Emelyanov xemul at parallels.com
Thu Oct 23 06:43:20 PDT 2014


On 10/14/2014 11:01 AM, Cyrill Gorcunov wrote:
> On Fri, Oct 10, 2014 at 3:09 PM, Cyrill Gorcunov <gorcunov at openvz.org> wrote:
>> This would allow to restore parameters with user namespaces
>> enabled.
>>
>> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> 
> Update attached, otherwise arm32 is not happy with
> @args->mm_saved_auxv_size types
> 
> +	if (args->prctl_may_use_mm_map) {
> +		struct prctl_mm_map prctl_map = {
> +			.start_code	= args->mm.mm_start_code,
> +			.end_code	= args->mm.mm_end_code,
> +			.start_data	= args->mm.mm_start_data,
> +			.end_data	= args->mm.mm_end_data,
> +			.start_stack	= args->mm.mm_start_stack,
> +			.start_brk	= args->mm.mm_start_brk,
> +			.brk		= args->mm.mm_brk,
> +			.arg_start	= args->mm.mm_arg_start,
> +			.arg_end	= args->mm.mm_arg_end,
> +			.env_start	= args->mm.mm_env_start,
> +			.env_end	= args->mm.mm_env_end,
> +			.auxv_size	= args->mm_saved_auxv_size,
> +			.auxv		= (void *)args->mm_saved_auxv,
> +			.exe_fd		= args->fd_exe_link,
> +		};
> +		ret = sys_prctl_safe(PR_SET_MM, PR_SET_MM_MAP, (long)&prctl_map, sizeof(prctl_map));
> +		sys_close(args->fd_exe_link);
> +	} else {
> +		ret  = sys_prctl_safe(PR_SET_MM, PR_SET_MM_START_CODE,	(long)args->mm.mm_start_code, 0);
> +		ret |= sys_prctl_safe(PR_SET_MM, PR_SET_MM_END_CODE,	(long)args->mm.mm_end_code, 0);
> +		ret |= sys_prctl_safe(PR_SET_MM, PR_SET_MM_START_DATA,	(long)args->mm.mm_start_data, 0);
> +		ret |= sys_prctl_safe(PR_SET_MM, PR_SET_MM_END_DATA,	(long)args->mm.mm_end_data, 0);
> +		ret |= sys_prctl_safe(PR_SET_MM, PR_SET_MM_START_STACK,	(long)args->mm.mm_start_stack, 0);
> +		ret |= sys_prctl_safe(PR_SET_MM, PR_SET_MM_START_BRK,	(long)args->mm.mm_start_brk, 0);
> +		ret |= sys_prctl_safe(PR_SET_MM, PR_SET_MM_BRK,		(long)args->mm.mm_brk, 0);
> +		ret |= sys_prctl_safe(PR_SET_MM, PR_SET_MM_ARG_START,	(long)args->mm.mm_arg_start, 0);
> +		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, args->mm_saved_auxv_size);
> +
> +		/*
> +		 * Because of requirements applied from kernel side
> +		 * we need to restore /proc/pid/exe symlink late,
> +		 * after old existing VMAs are superseded with
> +		 * new ones from image file.
> +		 */
> +		ret |= restore_self_exe_late(args);
> +	}

I don't understand the need in args->prctl_may_use_mm_map. Why not just

ret = prctl(PR_SET_MM< PR_SET_MM_MAP, ...);
if (ret == -EINVAL) {
	ret = <old code>
}

?

Thanks,
Pavel



More information about the CRIU mailing list