lkml.org 
[lkml]   [2022]   [Apr]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/5] sched,ptrace: Fix ptrace_check_attach() vs PREEMPT_RT
On Wed, Apr 13, 2022 at 09:20:53PM +0200, Peter Zijlstra wrote:
> On Wed, Apr 13, 2022 at 08:59:10PM +0200, Oleg Nesterov wrote:
>
>
> > + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> > + // wrong, needs siglock
> > + current->jobctl &= ~JOBCTL_TRACED_XXX;
> > + wake_up_bit(&current->jobctl, ~JOBCTL_TRACED_XXX_BIT);
> __wake_up_common_lock()
> spin_lock_irqsave()
> current_save_and_set_rtlock_wait_state();
>
> > + if (wait_on_bit(&task->jobctl, JOBCTL_TRACED_XXX_BIT, TASK_KILLABLE))
> > + return -EINTR;
> > + // now that the tracee cleared JOBCTL_TRACED_XXX_BIT
> > + // wait_task_inactive() should succeed or fail "really soon".
> > + if (!wait_task_inactive(child, __TASK_TRACED))
> > + return ret;
>
>
> *whoopsie* ?
>
> > preempt_enable_no_resched();
> > freezable_schedule();
> > cgroup_leave_frozen(true);

Something that might work; since there's only the one ptracer, is to
instead do something like:

current->jobctl &= ~JOBCTL_TRACED_XXX; // siglock
if (current->ptrace)
wake_up_process(current->parent);
preempt_enable_no_resched();
schedule();


vs

for (;;) {
set_current_state(TASK_UNINTERRUPTIBLE);
if (!(p->jobctl & JOBCTL_TRACED_XXX))
break;
schedule();
}
__set_current_state(TASK_RUNNING);

if (!wait_task_inactive(...))


ptrace_detach() needs some additional magic as well I think, but this
might just work.

\
 
 \ /
  Last update: 2022-04-13 21:59    [W:0.153 / U:1.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site