From: Oleg Nesterov <oleg@redhat.com>
To: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Roland McGrath <roland@hack.frob.com>, Tejun Heo <tj@kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: ptrace() hangs on attempt to seize/attach stopped & frozen task
Date: Mon, 9 Nov 2015 19:55:06 +0100 [thread overview]
Message-ID: <20151109185506.GA22744@redhat.com> (raw)
In-Reply-To: <5640B7F2.70406@virtuozzo.com>
Hi,
On 11/09, Andrey Ryabinin wrote:
>
> Hi,
>
> So, the ptrace() hangs if we try to attach to stopped task from freezing cgroup.
> It seems this was introduced by 5d8f72b55c2756("freezer: change ptrace_stop/do_signal_stop to use freezable_schedule()").
quite possible...
> See below for the exact scenario and small script to reproduce this.
>
>
> Tracee: Tracer:
> static bool do_signal_stop(int signr)
> __set_current_state(TASK_STOPPED);
> freezable_schedule();
> freezer_do_not_count();
> schedule(); /* waiting for wake up */
>
> ptrace_attach()
> if (task_is_stopped(task) &&
> task_set_jobctl_pending(task, JOBCTL_TRAP_STOP | JOBCTL_TRAPPING))
> signal_wake_up_state(task, __TASK_STOPPED);
>
> /* woken up by ptrace_attach() */
> freezer_count();
> __refrigerator()
> /* And here we will hang, because tracee is now frozen in __refrigerator() */
> wait_on_bit(&task->jobctl, JOBCTL_TRAPPING_BIT,
> TASK_UNINTERRUPTIBLE);
Thanks. All I can say I never liked this wait_on_bit() ;)
I need to think, but *at first glance* we can move this wait-for-stopped-
traced-transition into do_wait() path, and this way clear_jobctl_trapping()
can use __wake_up_parent(). Perhaps we just need to modify task_stopped_code()
to take JOBCTL_TRAPPING into account...
Sure, debugger will block in sys_wait() after PTRACE_ATTACH/SEIZE. But this
does not really differ from the case when the tracee was already frozen;
SIGSTOP sent by ATTACH or PTRACE_INTERRUPT, so debugger will equally block
in do_wait() until the tracee is unfrozen.
Oleg.
next prev parent reply other threads:[~2015-11-09 17:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-09 15:12 ptrace() hangs on attempt to seize/attach stopped & frozen task Andrey Ryabinin
2015-11-09 18:55 ` Oleg Nesterov [this message]
2015-11-09 18:02 ` Tejun Heo
2015-11-10 20:20 ` Oleg Nesterov
2015-11-16 18:45 ` Tejun Heo
2015-11-17 19:34 ` Oleg Nesterov
2015-11-17 18:57 ` Tejun Heo
2015-11-19 16:49 ` Pedro Alves
2015-11-19 17:47 ` Oleg Nesterov
2015-11-19 18:08 ` Pedro Alves
2015-11-10 20:20 ` Oleg Nesterov
2015-11-19 18:47 ` [PATCH 0/2] (Was: ptrace() hangs on attempt to seize/attach stopped & frozen task) Oleg Nesterov
2015-11-19 18:47 ` [PATCH 1/2] ptrace: make wait_on_bit(JOBCTL_TRAPPING_BIT) in ptrace_attach() killable Oleg Nesterov
2015-11-23 23:05 ` Tejun Heo
2015-11-19 18:47 ` [PATCH 2/2] ptrace: task_stopped_code(ptrace => true) can't see TASK_STOPPED task Oleg Nesterov
2015-11-23 23:15 ` Tejun Heo
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=20151109185506.GA22744@redhat.com \
--to=oleg@redhat.com \
--cc=aryabinin@virtuozzo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@hack.frob.com \
--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 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.