]> git.baikalelectronics.ru Git - kernel.git/commit
ptrace: fix exit_ptrace() vs ptrace_traceme() race
authorOleg Nesterov <oleg@redhat.com>
Mon, 13 Apr 2009 21:40:03 +0000 (14:40 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 13 Apr 2009 22:04:31 +0000 (15:04 -0700)
commitd6a9b16c4cb3ebfc6a4de6978d181d7b901840d2
tree3d2dd4672db69b9d3b7f35e06b0fb90ca4d8cc12
parent6e76c52ef235b1d2d11939b1bcc1a49d0799767b
ptrace: fix exit_ptrace() vs ptrace_traceme() race

Pointed out by Roland.  The bug was recently introduced by me in
"forget_original_parent: split out the un-ptrace part", commit
5743853a7cc8c7a298fd39005246f1eba7aea200.

Since that patch we have a window after exit_ptrace() drops tasklist and
before forget_original_parent() takes it again.  In this window the child
can do ptrace(PTRACE_TRACEME) and nobody can untrace this child after
that.

Change ptrace_traceme() to not attach to the exiting ->real_parent.  We
don't report the error in this case, we pretend we attach right before
->real_parent calls exit_ptrace() which should untrace us anyway.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/ptrace.c