Thread (33 messages) 33 messages, 5 authors, 2017-06-07

[PATCH 14/26] wait: Move changing of ptrace from wait_consider_task into wait_task_stopped

From: Eric W. Biederman <hidden>
Date: 2017-06-06 19:16:54
Also in: lkml
Subsystem: the rest · Maintainer: Linus Torvalds

With the freeing and slaying of zombies moved earlier in wait_consider_task
changing of the ptrace value only effects the clearing of notask_error and
wait_task_stopped.  Move the changing of ptrace into wait_task_stopped.
The value of ptrace coming into the code clearing notask_error is left
at it's original value.

Signed-off-by: "Eric W. Biederman" <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
---
 kernel/exit.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/kernel/exit.c b/kernel/exit.c
index 9b70e21c960d..dbf3fce00a1f 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1194,6 +1194,16 @@ static int wait_task_stopped(struct wait_opts *wo,
 	pid_t pid;
 
 	/*
+	 * Hide group stop state from real parent; otherwise a single
+	 * stop can be reported twice as group and ptrace stop.  If a
+	 * ptracer wants to distinguish these two events for its own
+	 * children it should create a separate process which takes the
+	 * role of real parent.
+	 */
+	if (!ptrace && p->ptrace && !ptrace_reparented(p))
+		ptrace = 1;
+
+	/*
 	 * Traditionally we see ptrace'd stopped tasks regardless of options.
 	 */
 	if (!ptrace && !(wo->wo_flags & WUNTRACED))
@@ -1370,18 +1380,6 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
 		return 0;
 	}
 
-	if (likely(!ptrace) && unlikely(p->ptrace)) {
-		/*
-		 * Hide group stop state from real parent; otherwise a single
-		 * stop can be reported twice as group and ptrace stop.  If a
-		 * ptracer wants to distinguish these two events for its own
-		 * children it should create a separate process which takes the
-		 * role of real parent.
-		 */
-		if (!ptrace_reparented(p))
-			ptrace = 1;
-	}
-
 	if (exit_state == EXIT_ZOMBIE) {
 		/*
 		 * Allow access to stopped/continued state via zombie by
@@ -1403,7 +1401,8 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
 		 * target task dies.  Only continued and exited can happen.
 		 * Clear notask_error if WCONTINUED | WEXITED.
 		 */
-		if (likely(!ptrace) || (wo->wo_flags & (WCONTINUED | WEXITED)))
+		if ((!ptrace && (!p->ptrace || ptrace_reparented(p))) ||
+		    (wo->wo_flags & (WCONTINUED | WEXITED)))
 			wo->notask_error = 0;
 	} else {
 		/*
-- 
2.10.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help