projects/linux·commit 28d838cc

Fix ptrace self-attach rule

28d838cc · Linus Torvalds <[email protected]> · 2005-11-09 11:33:07 -08:00

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 <[email protected]>
Commit
28d838cc4dfea980cb6eda0a7409cbf91889ca74
Parents
ac111bfa

Changes

1 files changed · +1 −1

FileStatusAddDelContent
kernel/ptrace.cmodified+1−1View file

kernel/ptrace.c

View file
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 5b8dd98..b88d418 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)