From: John Blackwood <john.blackwood@ccur.com>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: linux-kernel@vger.kernel.org, Roland McGrath <roland@redhat.com>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
Sven-Thorsten Dietrich <sdietrich@novell.com>,
bugsy@ccur.com
Subject: Re: [RFC] [PATCH] selective signal ptracing
Date: Mon, 18 Jun 2007 15:24:04 -0400 [thread overview]
Message-ID: <4676DBD4.2030909@ccur.com> (raw)
> Subject: Re: [RFC] [PATCH] selective signal ptracing
> From: Oleg Nesterov <oleg@tv-sign.ru>
> Date: Sat, 16 Jun 2007 13:24:15 +0400
> To: John Blackwood <john.blackwood@ccur.com>
> CC: Alan Cox <alan@lxorguk.ukuu.org.uk>, Roland McGrath
<roland@redhat.com>, linux-kernel@vger.kernel.org
>
> John Blackwood wrote:
> > >
> > > By default all signals are ptraced as before. However, a debugger
> > > may now modify the set of per-task ptraced signals, where only the
> > > signals in this ptrace signal mask will be ptraced.
>
> I must admit, I agree with Roland...
>
> > > +void ptrace_update_traced_signals(struct task_struct *child,
> > > + sigset_t *new_smaskp)
> > > +{
> > > [...snip...]
> > > +
> > > + spin_lock_irqsave(&child->sighand->siglock, flags);
> > > +
> > > + if (child->sighand == NULL) {
>
> How so?
>
> Oleg.
Hi Oleg.
Right, this above is not a good check for a NULL sighand.
Possibly, this routine could use something like the
rcu_read_lock()/lock_task_sighand() sequences used elsewhere
(shown below).
The whole ptrace_update_traced_signals() where we drain ignored signals
is not dealt with today by ptraced tasks when the debugger exits or
detaches from a target task. So this whole routine is not entirely
related just to selective signal ptracing.
Thanks for you input.
diff -rup linux-2.6.22-rc4-git5.old/kernel/exit.c
linux-2.6.22-rc4-git5.new/kernel/exit.c
--- linux-2.6.22-rc4-git5.old/kernel/exit.c 2007-06-18
14:36:09.000000000 -0400
+++ linux-2.6.22-rc4-git5.new/kernel/exit.c 2007-06-18
14:31:16.000000000 -0400
+/*
+ * void ptrace_update_traced_signals(
+ * struct task_struct *child, sigset_t *new_smaskp)
+ *
+ * Update the signal mask of ptraced signals, removing any ignored
+ * pending signals that are no longer ptraced. 'new_smaskp' points
+ * to the new ptrace signal mask which will be stored into
+ * child->ptrace_sigmask.
+ */
+void ptrace_update_traced_signals(struct task_struct *child,
+ sigset_t *new_smaskp)
+{
+ int sig = 0, index = 0;
+ unsigned long int flags;
+ sigset_t prev_smask;
+
+ /* Get signals that were previously, but no longer ptraced. */
+ signandsets(&prev_smask, &child->ptrace_sigmask, new_smaskp);
+ child->ptrace_sigmask = *new_smaskp;
+ rcu_read_lock();
+ while (!sigisemptyset(&prev_smask)) {
+ while (index < _NSIG_WORDS) {
+ if (prev_smask.sig[index]) {
+ sig = ffz(~prev_smask.sig[index]) +
+ (index * _NSIG_BPW) + 1;
+ break;
+ }
+ index++;
+ }
+ /* Remove signal from the previously ptraced signal mask. */
+ sigdelset(&prev_smask, sig);
+
+ if (!lock_task_sighand(child, &flags)) {
+ /* This task is exiting, so just return. */
+ unlock_task_sighand(child, &flags);
+ rcu_read_unlock();
+ return;
+ }
+ if (!sig_ignored(child, sig)) {
+ unlock_task_sighand(child, &flags);
+ continue;
+ }
+ /* Remove any queued signals - they should now be ignored. */
+ rm_from_queue(sigmask(sig), &child->pending);
+ rm_from_queue(sigmask(sig), &child->signal->shared_pending);
+ unlock_task_sighand(child, &flags);
+ }
+ rcu_read_unlock();
+}
next reply other threads:[~2007-06-18 19:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-18 19:24 John Blackwood [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-06-16 9:24 [RFC] [PATCH] selective signal ptracing Oleg Nesterov
2007-06-15 14:32 John Blackwood
2007-06-15 19:42 ` Roland McGrath
2007-06-15 23:26 ` Alan Cox
2007-06-15 23:39 ` Roland McGrath
2007-06-17 0:11 ` Benjamin Herrenschmidt
2007-06-17 1:29 ` Roland McGrath
2007-06-18 13:15 ` Josh Boyer
2007-06-19 1:15 ` Benjamin Herrenschmidt
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=4676DBD4.2030909@ccur.com \
--to=john.blackwood@ccur.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=bugsy@ccur.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@tv-sign.ru \
--cc=roland@redhat.com \
--cc=sdietrich@novell.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