[CRIU] [PATCH] parasite: Don't keep code_orig on parasite_ctl

Andrew Vagin avagin at parallels.com
Wed Oct 15 10:34:40 PDT 2014


On Tue, Oct 14, 2014 at 05:54:43PM +0400, Pavel Emelyanov wrote:
> We need this only once -- while calling the mmap from remote
> context -- so it's enough to have on-stack variable.
>

Acked-by: Andrew Vagin <avagin at parallels.com>

> Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
> ---
>  include/parasite-syscall.h | 1 -
>  parasite-syscall.c         | 9 +++++----
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/include/parasite-syscall.h b/include/parasite-syscall.h
> index 67840fc..c4fb118 100644
> --- a/include/parasite-syscall.h
> +++ b/include/parasite-syscall.h
> @@ -46,7 +46,6 @@ struct parasite_ctl {
>  
>  	unsigned long		parasite_ip;				/* service routine start ip */
>  	unsigned long		syscall_ip;				/* entry point of infection */
> -	u8			code_orig[BUILTIN_SYSCALL_SIZE];
>  
>  	unsigned int		*addr_cmd;				/* addr for command */
>  	void			*addr_args;				/* address for arguments */
> diff --git a/parasite-syscall.c b/parasite-syscall.c
> index 7cc1a84..41ae3c8 100644
> --- a/parasite-syscall.c
> +++ b/parasite-syscall.c
> @@ -208,14 +208,15 @@ int __parasite_execute_syscall(struct parasite_ctl *ctl, user_regs_struct_t *reg
>  {
>  	pid_t pid = ctl->pid.real;
>  	int err;
> +	u8 code_orig[BUILTIN_SYSCALL_SIZE];
>  
>  	/*
>  	 * Inject syscall instruction and remember original code,
>  	 * we will need it to restore original program content.
>  	 */
> -	memcpy(ctl->code_orig, code_syscall, sizeof(ctl->code_orig));
> +	memcpy(code_orig, code_syscall, sizeof(code_orig));
>  	if (ptrace_swap_area(pid, (void *)ctl->syscall_ip,
> -			     (void *)ctl->code_orig, sizeof(ctl->code_orig))) {
> +			     (void *)code_orig, sizeof(code_orig))) {
>  		pr_err("Can't inject syscall blob (pid: %d)\n", pid);
>  		return -1;
>  	}
> @@ -224,8 +225,8 @@ int __parasite_execute_syscall(struct parasite_ctl *ctl, user_regs_struct_t *reg
>  	if (!err)
>  		err = parasite_trap(ctl, pid, regs, &ctl->orig);
>  
> -	if (ptrace_poke_area(pid, (void *)ctl->code_orig,
> -			     (void *)ctl->syscall_ip, sizeof(ctl->code_orig))) {
> +	if (ptrace_poke_area(pid, (void *)code_orig,
> +			     (void *)ctl->syscall_ip, sizeof(code_orig))) {
>  		pr_err("Can't restore syscall blob (pid: %d)\n", ctl->pid.real);
>  		err = -1;
>  	}
> -- 
> 1.8.4.2
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list