From: Linus Torvalds Date: Wed, 9 Nov 2005 19:33:07 +0000 (-0800) Subject: Fix ptrace self-attach rule X-Git-Tag: v2.6.15-rc1~66 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28d838cc4dfea980cb6eda0a7409cbf91889ca74;p=linux-2.6 Fix ptrace self-attach rule Before we did CLONE_THREAD, the way to check whether we were attaching to ourselves was to just check "current == task", but with CLONE_THREAD we should check that the thread group ID matches instead. Signed-off-by: Linus Torvalds --- diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 5b8dd98a23..b88d4186cd 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -155,7 +155,7 @@ int ptrace_attach(struct task_struct *task) retval = -EPERM; if (task->pid <= 1) goto bad; - if (task == current) + if (task->tgid == current->tgid) goto bad; /* the same process cannot be attached many times */ if (task->ptrace & PT_PTRACED)