aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2008-08-07 19:55:03 -0400
committerRoland McGrath <roland@redhat.com>2008-08-07 20:18:47 -0400
commit5861bbfcc10fc0358abf52c7d22850c8d180f0b0 (patch)
tree066a66bd465741973879675b150f517032adcbfa
parent685d87f7ccc649ab92b55e18e507a65d0e694eb9 (diff)
tracehook: fix CLONE_PTRACE
In the change in commit 09a05394fe2448a4139b014936330af23fa7ec83, I overlooked two nits in the logic and this broke using CLONE_PTRACE when PTRACE_O_TRACE* are not being used. A parent that is itself traced at all but not using PTRACE_O_TRACE*, using CLONE_PTRACE would have its new child fail to be traced. A parent that is not itself traced at all that uses CLONE_PTRACE (which should be a no-op in this case) would confuse the bookkeeping and lead to a crash at exit time. This restores the missing checks and fixes both failure modes. Reported-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Roland McGrath <roland@redhat.com>
-rw-r--r--include/linux/ptrace.h2
-rw-r--r--include/linux/tracehook.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index fd31756e1a00..ea7416c901d1 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -172,7 +172,7 @@ static inline void ptrace_init_task(struct task_struct *child, bool ptrace)
172 child->ptrace = 0; 172 child->ptrace = 0;
173 if (unlikely(ptrace)) { 173 if (unlikely(ptrace)) {
174 child->ptrace = current->ptrace; 174 child->ptrace = current->ptrace;
175 __ptrace_link(child, current->parent); 175 ptrace_link(child, current->parent);
176 } 176 }
177} 177}
178 178
diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
index ab3ef7aefa95..b48d81969574 100644
--- a/include/linux/tracehook.h
+++ b/include/linux/tracehook.h
@@ -280,7 +280,7 @@ static inline void tracehook_report_clone(int trace, struct pt_regs *regs,
280 unsigned long clone_flags, 280 unsigned long clone_flags,
281 pid_t pid, struct task_struct *child) 281 pid_t pid, struct task_struct *child)
282{ 282{
283 if (unlikely(trace)) { 283 if (unlikely(trace) || unlikely(clone_flags & CLONE_PTRACE)) {
284 /* 284 /*
285 * The child starts up with an immediate SIGSTOP. 285 * The child starts up with an immediate SIGSTOP.
286 */ 286 */