Re: [PATCH v2 2/5] sched,ptrace: Fix ptrace_check_attach() vs PREEMPT_RT
From: Eric W. Biederman
Date: Tue Apr 26 2022 - 13:19:47 EST
Oleg Nesterov <oleg@xxxxxxxxxx> writes:
> On 04/25, Eric W. Biederman wrote:
>>
>> I don't see JOBCTL_TRACED_QUIESCE being cleared "if (!current->ptrace)".
>
> As Peter explained, in this case we can rely on __ptrace_unlink() which
> should clear this flag.
I had missed that that signal_wake_up_state was clearing
JOBCTL_TRACED_QUIESCE.
Relying on __ptrace_unlink assumes the __ptrace_unlink happens after
siglock is taken before calling ptrace_stop. Especially with the
ptrace_notify in signal_delivered that does not look guaranteed.
The __ptrace_unlink could also happen during arch_ptrace_stop.
Relying on siglock is sufficient because __ptrace_unlink holds siglock
over clearing task->ptrace. Which means that the simple fix for this is
to just test task->ptrace before we set JOBCTL_TRACED_QUEIESCE.
Eric