All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oren Laadan <orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
To: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: Luis Rilling
	<Louis.Rilling-aw0BnHfMbSpBDgjK7y7TUQ@public.gmane.org>,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: [PATCH 3/4] c/r: [signal] pending signals (private, shared)
Date: Mon, 17 Aug 2009 16:14:29 -0400	[thread overview]
Message-ID: <4A89BA25.3060802@librato.com> (raw)
In-Reply-To: <87vdkm5qvv.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>



Dan Smith wrote:
> OL> +static int load_siginfo(siginfo_t *info, struct ckpt_hdr_siginfo *si)
> OL> +{
> OL> +	if (!valid_signal(si->signo))
> OL> +		return -EINVAL;
> OL> +
> OL> +	info->si_signo = si->signo;
> OL> +	info->si_errno = si->_errno;
> OL> +	info->si_code = si->code;
> OL> +
> OL> +	/* TODO: validate remaining signal fields */
> OL> +
> OL> +	switch(info->si_code & __SI_MASK) {
> OL> +	case __SI_TIMER:
> OL> +		info->si_tid = si->pid;
> OL> +		info->si_overrun = si->uid;
> OL> +		info->si_int = si->sigval_int;
> OL> +		info->si_sys_private = si->utime;
> OL> +		break;
> OL> +	case __SI_POLL:
> OL> +		info->si_band = si->pid;
> OL> +		info->si_fd = si->sigval_int;
> OL> +		break;
> OL> +	case __SI_FAULT:
> OL> +		info->si_addr = (void __user *) (unsigned long) si->sigval_ptr;
> OL> +#ifdef __ARCH_SI_TRAPNO
> OL> +		info->si_trapno = si->sigval_int;
> OL> +#endif
> OL> +		break;
> OL> +	case __SI_CHLD:
> OL> +		info->si_pid = si->pid;
> OL> +		info->si_uid = si->uid;
> OL> +		info->si_status = si->sigval_int;
> OL> +		info->si_stime = si->stime;
> OL> +		info->si_utime = si->utime;
> OL> +		break;
> OL> +	case __SI_KILL:
> OL> +	case __SI_RT:
> OL> +	case __SI_MESGQ:
> OL> +		info->si_pid = si->pid;
> OL> +		info->si_uid = si->uid;
> OL> +		info->si_ptr = (void __user *) (unsigned long) si->sigval_ptr;
> OL> +		break;
> OL> +	default:
> OL> +		return -EINVAL;
> OL> +	}
> OL> +
> OL> +	return 0;
> OL> +}
> OL> +
> 
> This seems like a perfect place to use the CKPT_COPY() macros, if
> we're going to have them.  This and the save equivalent could be
> almost identical.

Hehe... "if" ?!

Anyway, I'll see what I can do.


> OL> +static int restore_sigpending(struct ckpt_ctx *ctx, struct sigpending *pending)
> OL> +{
> OL> +	struct ckpt_hdr_sigpending *h;
> OL> +	struct ckpt_hdr_siginfo *si;
> OL> +	struct sigqueue *q;
> OL> +	int ret = 0;
> OL> +
> OL> +	h = ckpt_read_buf_type(ctx, 0, CKPT_HDR_SIGPENDING);
> OL> +	if (IS_ERR(h))
> OL> +		return PTR_ERR(h);
> OL> +
> OL> +	INIT_LIST_HEAD(&pending->list);
> OL> +	load_sigset(&pending->signal, &h->signal);
> OL> +
> OL> +	si = h->siginfo;
> OL> +	while (h->nr_pending--) {
> OL> +		q = sigqueue_alloc();
> OL> +		if (!q) {
> OL> +			ret = -ENOMEM;
> OL> +			break;
> OL> +		}
> OL> +
> OL> +		ret = load_siginfo(&q->info, si++);
> 
> I think there should be a sanity check here, no?  The checkpoint
> stream claims h->nr_pending structures in h->siginfo, but we can't
> trust that we're not going to march through memory to a segv unless we
> check that the header length matches your calculation in
> checkpoint_sigpending().
> 

I think you are right :p

Thanks,

Oren.

  parent reply	other threads:[~2009-08-17 20:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-14 22:07 c/r: support for pending signals (v3) Oren Laadan
     [not found] ` <1250287636-16463-1-git-send-email-orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-08-14 22:07   ` [PATCH 1/4] c/r: [signal] blocked and template for shared signals Oren Laadan
2009-08-14 22:07   ` [PATCH 2/4] c/r: [signal] checkpoint/restart of rlimit Oren Laadan
2009-08-14 22:07   ` [PATCH 3/4] c/r: [signal] pending signals (private, shared) Oren Laadan
     [not found]     ` <1250287636-16463-4-git-send-email-orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-08-17 16:47       ` Dan Smith
     [not found]         ` <87vdkm5qvv.fsf-FLMGYpZoEPULwtHQx/6qkW3U47Q5hpJU@public.gmane.org>
2009-08-17 20:14           ` Oren Laadan [this message]
2009-08-14 22:07   ` [PATCH 4/4] c/r: [signal] support for real/virt/prof itimers Oren Laadan
2009-08-19  9:12   ` c/r: support for pending signals (v3) Louis Rilling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A89BA25.3060802@librato.com \
    --to=orenl-rdfvbdnroixbdgjk7y7tuq@public.gmane.org \
    --cc=Louis.Rilling-aw0BnHfMbSpBDgjK7y7TUQ@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.