[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 6 Jun 2017 14:03:26 -0500
From: "Eric W. Biederman" <ebiederm@...ssion.com>
To: linux-kernel@...r.kernel.org
Cc: linux-api@...r.kernel.org,
Linus Torvalds <torvalds@...ux-foundation.org>,
Oleg Nesterov <oleg@...hat.com>,
Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Kees Cook <keescook@...omium.org>,
Roland McGrath <roland@...k.frob.com>,
Al Viro <viro@...IV.linux.org.uk>,
David Howells <dhowells@...hat.com>,
"Michael Kerrisk (man-pages)" <mtk.manpages@...il.com>,
"Eric W. Biederman" <ebiederm@...ssion.com>
Subject: [PATCH 14/26] wait: Move changing of ptrace from wait_consider_task into wait_task_stopped
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@...ssion.com>
---
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
Powered by blists - more mailing lists