lkml.org 
[lkml]   [2017]   [Feb]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] ptrace: fix PTRACE_LISTEN race corrupting task->state
Date
Oleg Nesterov <oleg@redhat.com> writes:

> On 02/21, bsegall@google.com wrote:
>>
>> In PT_SEIZED + LISTEN mode SIGSTOP/SIGCONT signals cause a wakeup
>> against __TASK_TRACED. If this races with the ptrace_unfreeze_traced at
>> the end of a PTRACE_LISTEN, this can wake the task /after/ the check
>> against __TASK_TRACED, but before the reset of state to TASK_TRACED.
>
> Oh, thanks...
>
> note also that PTRACE_LISTEN itself can do ptrace_signal_wake_up(true),
>
>> This causes it to instead clobber TASK_WAKING,
>
> even if it is already TASK_RUNNING it is simply wrong to set TASK_TRACED
> in both cases, right?

Yeah, that's also wrong and could possibly lead to different errors, but
is likely to work out by accident when say ttwu checks on_rq and sees true.

>
> Thanks. The patch looks good at first glance, but let me think a bit...
> perhaps we should change PTRACE_LISTEN instead, not sure.
>
> Oleg.

\
 
 \ /
  Last update: 2017-02-22 18:57    [W:0.117 / U:0.776 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site