Skip to contentSkip to conversation

ptrace_check_attach: remove unneeded ->signal != NULL check

PATCH In review Oleg Nesterov 2 participants 2 messages Nov 21, 2007 – Dec 11, 2007 ptrace support

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 ptrace_check_attach: remove unneeded ->signal != NULL check

It is not possible to see the PT_PTRACED task without ->signal/sighand under tasklist_lock, release_task() does ptrace_unlink() first. If the task was already released before, ptrace_attach() can't succeed and set PT_PTRACED. Remove this check.

kernel/ptrace.c renamed from kernel/ptrace.c~3_signal +5 -2
@@ -99,9 +99,12 @@ int ptrace_check_attach(struct task_stru
 	 * be changed by us so it's not changing right after this.
 	 */
 	read_lock(&tasklist_lock);
-	if ((child->ptrace & PT_PTRACED) && child->parent == current &&
-	     child->signal != NULL) {
+	if ((child->ptrace & PT_PTRACED) && child->parent == current) {
 		ret = 0;
+		/*
+		 * child->sighand can't be NULL, release_task()
+		 * does ptrace_unlink() before __exit_signal().
+		 */
 		spin_lock_irq(&child->sighand->siglock);
 		if (is_task_stopped(child))
 			__set_task_state(child, TASK_TRACED);