public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Patrick Donnelly <pdonnel3@nd.edu>
Cc: Tejun Heo <tj@kernel.org>, linux-kernel@vger.kernel.org
Subject: Re: Question regarding ptrace work for LInux v3.1
Date: Mon, 21 Mar 2016 20:35:25 +0100	[thread overview]
Message-ID: <20160321193524.GA9494@redhat.com> (raw)
In-Reply-To: <CALJO4zEH6tLLQQ33qFJ8STTLrRPcbvPqOWKUT8=Qu3-S82Ecng@mail.gmail.com>

On 03/21, Patrick Donnelly wrote:
>
> On Mon, Mar 21, 2016 at 3:07 PM, Oleg Nesterov <oleg@redhat.com> wrote:
> >
> > Yes, exactly, you need to see the initial SIGSTOP or another event which
> > can be reported before it.
>
> Assuming a SIGSTOP is being silenced, is there anything we can do to
> forcibly start tracing syscalls? (For kernels without PTRACE_SEIZE)

No. Only PTRACE_SYSCALL can set TIF_SYSCALL_TRACE.

> >         case SIGSTOP:
> >         /* Black magic to get threads working on old Linux kernels... */
> >
> >         if(p->nsyscalls == 0) { /* stop before we begin running the process */
> >                 debug(D_DEBUG, "suppressing bootstrap SIGSTOP for %d",pid);
> >                 signum = 0; /* suppress delivery */
> >                 kill(p->pid,SIGCONT);
> >         }
> >         break;
> >
> > doesn't look right. Note that kill(pid,SIGCONT) affects the whole thread-
> > group. So if this kill() races with another thread doing clone() you can
> > hit the problem you described.
>
> You're right, that should be tkill! I will give that a try and report
> back if that solved the issue for our collaborators...

Ah, sorry, I should have mentioned this...

No, tkill() won't help. See prepare_signal(), SIGCONT always removes
the SIG_KERNEL_STOP_MASK signals from all threads, not matter if it was
sent by tkill() or kill().

Perhaps you should just remove this kill(SIGCONT) ?

tracer_continue(signr => 0) should equally suppress the delivery. To
clarify this won't be right too, but without PTRACE_SEIZE you simply
can't write the code which handles the stop/cont/etc events correctly
anyway...

> >> > But unless you use PTRACE_SEIZE the same can happen on v3.1 so it seems
> >> > there is something else.
> >>
> >> Okay, it might be that PTRACE_SEIZE fixes it.
> >
> > Yes, but iiuc you do not see this problem on v3.1 even with PTRACE_ATTACH?
>
> I have not tested on >v3.1 with PTRACE_ATTACH.

OK, thanks. So perhaps this is not v3.0-specific.

Oleg.

  reply	other threads:[~2016-03-21 19:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CALJO4zGaZBzCEHsD4oan=nhpQasmxWiN535RLM+2bXngcabQmA@mail.gmail.com>
2016-03-21 17:47 ` Question regarding ptrace work for LInux v3.1 Oleg Nesterov
2016-03-21 18:28   ` Patrick Donnelly
2016-03-21 19:07     ` Oleg Nesterov
2016-03-21 19:24       ` Patrick Donnelly
2016-03-21 19:35         ` Oleg Nesterov [this message]
2016-03-23 14:12           ` Patrick Donnelly

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=20160321193524.GA9494@redhat.com \
    --to=oleg@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pdonnel3@nd.edu \
    --cc=tj@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox