[PATCH 11/22] ptrace_stop: do not assume the task is running after wake_up_quiescent()

Oleg Nesterov oleg at redhat.com
Sun Aug 7 19:15:45 UTC 2011


If ptrace_stop() sets TASK_TRACED and then detects we should not stop,
it can race with utrace_do_stop() which can see TASK_TRACED and add
TASK_UTRACED. In this case we should stop for utrace needs.

Signed-off-by: Oleg Nesterov <oleg at redhat.com>
---
 kernel/signal.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 57552e6..89e691d 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1829,6 +1829,14 @@ static void ptrace_stop(int exit_code, int why, int clear_code, siginfo_t *info)
 		if (clear_code)
 			current->exit_code = 0;
 		read_unlock(&tasklist_lock);
+
+		/*
+		 * It is possible that __TASK_UTRACED was added by utrace
+		 * while we were __TASK_TRACED and before we take ->siglock
+		 * for wake_up_quiescent(), we need to block in this case.
+		 * Otherwise this is unnecessary but absolutely harmless.
+		 */
+		schedule();
 	}
 
 	tracehook_finish_stop();
-- 
1.5.5.1



More information about the kernel mailing list