[PATCH 1] ptrace: cleanup ptrace_init_task()->ptrace_link() path

Oleg Nesterov oleg at redhat.com
Sun Nov 22 22:12:27 UTC 2009


(already in mm: ptrace-cleanup-ptrace_init_task-ptrace_link-path.patch)

No functional changes.

ptrace_init_task() looks confusing, as if we always auto-attach when
"bool ptrace" argument is true, while in fact we attach only if current
is traced.

Make the code more explicit and kill now unused ptrace_link().

Signed-off-by: Oleg Nesterov <oleg at redhat.com>
Acked-by: Roland McGrath <roland at redhat.com>
---

 include/linux/ptrace.h |   11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

--- V1/include/linux/ptrace.h~1_PTRACE_INIT_TASK	2009-06-19 01:12:47.000000000 +0200
+++ V1/include/linux/ptrace.h	2009-11-22 19:38:22.000000000 +0100
@@ -105,12 +105,7 @@ static inline int ptrace_reparented(stru
 {
 	return child->real_parent != child->parent;
 }
-static inline void ptrace_link(struct task_struct *child,
-			       struct task_struct *new_parent)
-{
-	if (unlikely(child->ptrace))
-		__ptrace_link(child, new_parent);
-}
+
 static inline void ptrace_unlink(struct task_struct *child)
 {
 	if (unlikely(child->ptrace))
@@ -169,9 +164,9 @@ static inline void ptrace_init_task(stru
 	INIT_LIST_HEAD(&child->ptraced);
 	child->parent = child->real_parent;
 	child->ptrace = 0;
-	if (unlikely(ptrace)) {
+	if (unlikely(ptrace) && (current->ptrace & PT_PTRACED)) {
 		child->ptrace = current->ptrace;
-		ptrace_link(child, current->parent);
+		__ptrace_link(child, current->parent);
 	}
 }
 




More information about the utrace-devel mailing list