[CRIU] [PATCH] [RFC] ptrace: peek and send siginfo

Cyrill Gorcunov gorcunov at openvz.org
Tue Nov 27 04:11:38 EST 2012


On Tue, Nov 27, 2012 at 01:41:40AM +0400, Andrey Vagin wrote:
> This functionality is required for checkpointing and restoring
> pending signals.
> 
> This patch adds two ptrace commands:
> * to get siginfo for any signal with a specified sequence number
> * to add a siginfo to a process
> 
> Could you comment this approach?

A few comments on implementation, while the idea looks reasonable for me.
(And don't forget to CC Oleg once you send it to LKML for review).

> +#ifdef CONFIG_CHECKPOINT_RESTORE
> +	case PTRACE_PEEK_SIGINFO:
> +		ret = do_peek_siginfo(addr & 0xffff, &siginfo, child, addr >> 16);

Shifts (as far as I remember) have undefined behaviour on sign propagation in C,
so I guess you better use plain ((long)addr > 0) predicate here.

> +		if (!ret)
> +			ret = copy_siginfo_to_user(datavp, &siginfo);
> +		break;
> +
> +	case PTRACE_SEND_SIGINFO:
> +		if (copy_from_user(&siginfo, datavp, sizeof siginfo))
> +			ret = -EFAULT;
> +		else
> +			ret = do_send_sig_info(siginfo.si_signo,
> +						&siginfo, child, addr ? 1 : 0);
> +		break;
> +#endif
> +
> +int do_peek_siginfo(int sig, siginfo_t *info, struct task_struct *tsk, s16 nr)
> +{

bool group maybe?

	Cyrill


More information about the CRIU mailing list