lkml.org 
[lkml]   [2022]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v2 2/5] sched,ptrace: Fix ptrace_check_attach() vs PREEMPT_RT
    On 04/21, Peter Zijlstra wrote:
    >
    > Rework ptrace_check_attach() / ptrace_unfreeze_traced() to not rely on
    > task->__state as much.

    Looks good after the quick glance... but to me honest I got lost and
    I need to apply these patches and read the code carefully.

    However, I am not able to do this until Monday, sorry.

    Just one nit for now,

    > static void ptrace_unfreeze_traced(struct task_struct *task)
    > {
    > - if (READ_ONCE(task->__state) != __TASK_TRACED)
    > + if (!task_is_traced(task))
    > return;
    >
    > WARN_ON(!task->ptrace || task->parent != current);
    >
    > - /*
    > - * PTRACE_LISTEN can allow ptrace_trap_notify to wake us up remotely.
    > - * Recheck state under the lock to close this race.
    > - */
    > spin_lock_irq(&task->sighand->siglock);
    > - if (READ_ONCE(task->__state) == __TASK_TRACED) {
    > + if (task_is_traced(task)) {

    I think ptrace_unfreeze_traced() should not use task_is_traced() at all.
    I think a single lockless

    if (task->jobctl & JOBCTL_DELAY_WAKEKILL)
    return;

    at the start should be enough?

    Nobody else can set this flag. It can be cleared by the tracee if it was
    woken up, so perhaps we can check it again but afaics this is not strictly
    needed.

    > +// WARN_ON_ONCE(!(task->jobctl & JOBCTL_DELAY_WAKEKILL));

    Did you really want to add the commented WARN_ON_ONCE?

    Oleg.

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