lkml.org 
[lkml]   [2013]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 2/4] ptrace: ensure arch_ptrace/ptrace_request can never race with SIGKILL
On Sun, Jan 20, 2013 at 11:25 AM, Oleg Nesterov <oleg@redhat.com> wrote:
> +
> +static void ptrace_unfreeze_traced(struct task_struct *task)
> +{
> + if (task->state != __TASK_TRACED)
> + return;
> +
> + if (WARN_ON(!task->ptrace || task->parent != current))
> + return;

This WARN_ON() is bogus.

Because you added the warning, you then need to make the callers check
for the whole PTRACE_UNATTACH.

So I think you should just remove the WARN_ON(), and then just call
ptrace_unfreeze_traced() unconditionally after you've successfully
done a ptrace_check_attach(). Just to keep the code simpler.

Also, in your corrected version, you had

+ if (!wait_task_inactive(child, __TASK_TRACED)) {
+ /* This can only happen if may_ptrace_stop() fails */
+ WARN_ON(child->state == __TASK_TRACED);
+ ret = -ESRCH;

where I actually think that the comment is not really helpful. It
doesn't really explain what he child can do to get to ptrace_stop() in
the first place, and what that does to the child state...

Linus


\
 
 \ /
  Last update: 2013-01-20 21:41    [W:0.112 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site