public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Vagin <avagin@parallels.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Andrey Vagin <avagin@openvz.org>, <linux-kernel@vger.kernel.org>,
	Roland McGrath <roland@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Michael Kerrisk <mtk.manpages@gmail.com>,
	Pavel Emelyanov <xemul@parallels.com>,
	Cyrill Gorcunov <gorcunov@openvz.org>
Subject: Re: [PATCH] ptrace: add ability to get/set signal-blocked mask
Date: Tue, 23 Apr 2013 14:59:18 +0400	[thread overview]
Message-ID: <20130423105917.GA11121@paralelels.com> (raw)
In-Reply-To: <20130422150710.GA30858@redhat.com>

On Mon, Apr 22, 2013 at 05:07:10PM +0200, Oleg Nesterov wrote:
> On 04/22, Oleg Nesterov wrote:
> >
> > On 04/22, Andrey Vagin wrote:
> > >
> > > +	case PTRACE_SETSIGMASK:
> > > +	{
> > > +		sigset_t new_set;
> > > +
> > > +		if (addr != sizeof(sigset_t)) {
> > > +			ret = -EINVAL;
> > > +			break;
> > > +		}
> > > +
> > > +		if (copy_from_user(&new_set, datavp, sizeof(sigset_t))) {
> > > +			ret = -EFAULT;
> > > +			break;
> > > +		}
> > > +
> > > +		sigdelsetmask(&new_set, sigmask(SIGKILL)|sigmask(SIGSTOP));
> > > +
> > > +		spin_lock_irq(&child->sighand->siglock);
> > > +		__set_task_blocked(child, &new_set);
> > > +		spin_unlock_irq(&child->sighand->siglock);
> >
> > No, please don't...
> >
> > set_current_blocked/__set_task_blocked assume that tsk == current.
> > If nothing else, note recalc_sigpending() in __set_task_blocked().

Thank you for the comment. It's my mistake.

> >
> > I don't understand "This method is not suitable for stopped tasks"

For example, a stopped process has a pending signal and this signal is
not blocked. crtools should dump its state, so that the process remains
in a stopped state with the same pending signal.

For dumping state crtools inject a parasite code with help POKE_DATA,
sets %rip on this code (PTRACE_SETREGS) and resumes the task
(PTRACE_CONT).

If signals are not blocked, the kernel starts to handle the signal after
resuming a process. It's out of our plan.

https://lkml.org/lkml/2011/7/20/138 - an example of code for injecting a
parasite code.

I hope the problem is become more clear.

> > from the changelog, but if you really need PTRACE_SETSIGMASK just
> > change ->blocked under siglock and do recalc_sigpending_tsk(child).
>                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> actually this is not necessary, the tracee will do recalc_sigpending()
> after resume. But perhaps a comment make sense.

__set_task_blocked executes retarget_shared_pending. I think it must be
called here too or am I wrong?

> 
> Oleg.
> 

  reply	other threads:[~2013-04-23 11:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-22  9:53 [PATCH] ptrace: add ability to get/set signal-blocked mask Andrey Vagin
     [not found] ` <20130422145704.GA30029@redhat.com>
2013-04-22 15:07   ` Oleg Nesterov
2013-04-23 10:59     ` Andrew Vagin [this message]
2013-04-23 13:11       ` Oleg Nesterov

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=20130423105917.GA11121@paralelels.com \
    --to=avagin@parallels.com \
    --cc=akpm@linux-foundation.org \
    --cc=avagin@openvz.org \
    --cc=gorcunov@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=oleg@redhat.com \
    --cc=roland@redhat.com \
    --cc=xemul@parallels.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox