public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Andrey Vagin <avagin@openvz.org>
Cc: 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 (v2)
Date: Tue, 23 Apr 2013 17:21:43 +0200	[thread overview]
Message-ID: <20130423152143.GA30125@redhat.com> (raw)
In-Reply-To: <1366729843-24148-1-git-send-email-avagin@openvz.org>

On 04/23, Andrey Vagin wrote:
>
> @@ -841,6 +841,48 @@ int ptrace_request(struct task_struct *child, long request,
>  			ret = ptrace_setsiginfo(child, &siginfo);
>  		break;
>  
> +	case PTRACE_GETSIGMASK:
> +		if (addr != sizeof(sigset_t)) {
> +			ret = -EINVAL;
> +			break;
> +		}
> +
> +		if (copy_to_user(datavp, &child->blocked, sizeof(sigset_t)))
> +			ret = -EFAULT;

Yes, we can do this lockless. Only the task itself (or the debugger with
this patch) can change ->blocked, and the tracee can't run.

> +	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));
> +
> +		/*
> +		 * Every thread does recalc_sigpending() after resume, so
> +		 * retarget_shared_pending() and recalc_sigpending() are not
> +		 * called here.
> +		 */
> +		spin_lock_irq(&child->sighand->siglock);
> +		child->blocked = new_set;
> +		spin_unlock_irq(&child->sighand->siglock);
> +
> +		ret = 0;
> +		break;
> +	}

And this looks fine too.

Personally I am not sure we need to check addr == sizeof(), debugger
should know what it does... But I won't argue.

Oleg.


  reply	other threads:[~2013-04-23 15:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-23 15:10 [PATCH] ptrace: add ability to get/set signal-blocked mask (v2) Andrey Vagin
2013-04-23 15:21 ` Oleg Nesterov [this message]
2013-05-06  8:03   ` Andrew Vagin
  -- strict thread matches above, loose matches on Subject: below --
2013-05-22 16:51 Andrey Vagin

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=20130423152143.GA30125@redhat.com \
    --to=oleg@redhat.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=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