Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1265906
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: ptrace() hangs on attempt to seize/attach stopped & frozen task |
| Date | 2015-11-09 19:00 +0100 |
| Message-ID | <qsYTw-18Q-9@gated-at.bofh.it> (permalink) |
| References | <qsWoF-89v-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
ptrace() hangs on attempt to seize/attach stopped & frozen task Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-11-09 16:20 +0100
Re: ptrace() hangs on attempt to seize/attach stopped & frozen task Oleg Nesterov <oleg@redhat.com> - 2015-11-09 19:00 +0100
Re: ptrace() hangs on attempt to seize/attach stopped & frozen task Tejun Heo <tj@kernel.org> - 2015-11-09 19:10 +0100
Re: ptrace() hangs on attempt to seize/attach stopped & frozen task Oleg Nesterov <oleg@redhat.com> - 2015-11-10 20:30 +0100
Re: ptrace() hangs on attempt to seize/attach stopped & frozen task Oleg Nesterov <oleg@redhat.com> - 2015-11-10 20:30 +0100
csiph-web