[CRIU] [PATCH 2/2] compel: Add compel_run_at helper

Pavel Emelyanov xemul at virtuozzo.com
Mon Dec 5 13:57:09 PST 2016


On 12/06/2016 12:15 AM, Cyrill Gorcunov wrote:
> Simply run tracee from specfied IP assuming
> it's arelady have trapping instruction in
> stream.
> 
> It's unsafe low-level function use with caution.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  compel/include/uapi/infect.h |  1 +
>  compel/src/lib/infect.c      | 11 +++++++++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/compel/include/uapi/infect.h b/compel/include/uapi/infect.h
> index 174c197bba1c..7b88a5634c5e 100644
> --- a/compel/include/uapi/infect.h
> +++ b/compel/include/uapi/infect.h
> @@ -73,6 +73,7 @@ extern int compel_syscall(struct parasite_ctl *ctl, int nr, unsigned long *ret,
>  		unsigned long arg5,
>  		unsigned long arg6);
>  extern int compel_run_in_thread(struct parasite_thread_ctl *tctl, unsigned int cmd);
> +extern int compel_run_at(struct parasite_ctl *ctl, unsigned long ip, user_regs_struct_t *ret_regs);
>  
>  /*
>   * The PTRACE_SYSCALL will trap task twice -- on
> diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c
> index fd92ee5d1da6..72cf20cdcba1 100644
> --- a/compel/src/lib/infect.c
> +++ b/compel/src/lib/infect.c
> @@ -590,6 +590,17 @@ int compel_execute_syscall(struct parasite_ctl *ctl,
>  	return err;
>  }
>  
> +int compel_run_at(struct parasite_ctl *ctl, unsigned long ip, user_regs_struct_t *ret_regs)

What's the use in ret_regs argument for a caller?

> +{
> +	user_regs_struct_t regs = ctl->orig.regs;
> +	int ret;
> +
> +	ret = parasite_run(ctl->rpid, PTRACE_CONT, ip, 0, &regs, &ctl->orig);
> +	if (!ret)
> +		ret = parasite_trap(ctl, ctl->rpid, ret_regs ? ret_regs : &regs, &ctl->orig);
> +	return ret;
> +}
> +
>  static int accept_tsock(struct parasite_ctl *ctl)
>  {
>  	int sock;
> 



More information about the CRIU mailing list