]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - include/linux/tracehook.h
ptrace: tracehook_report_clone: fix false positives
[linux-2.6.git] / include / linux / tracehook.h
index 6186a789d6c7a2f6d5c3ce7a3651a1db184b67ed..eb96603d92db0d556141cacf771ca01b26bd779d 100644 (file)
@@ -259,14 +259,12 @@ static inline void tracehook_finish_clone(struct task_struct *child,
 
 /**
  * tracehook_report_clone - in parent, new child is about to start running
- * @trace:             return value from tracehook_prepare_clone()
  * @regs:              parent's user register state
  * @clone_flags:       flags from parent's system call
  * @pid:               new child's PID in the parent's namespace
  * @child:             new child task
  *
- * Called after a child is set up, but before it has been started
- * running.  @trace is the value returned by tracehook_prepare_clone().
+ * Called after a child is set up, but before it has been started running.
  * This is not a good place to block, because the child has not started
  * yet.  Suspend the child here if desired, and then block in
  * tracehook_report_clone_complete().  This must prevent the child from
@@ -276,13 +274,14 @@ static inline void tracehook_finish_clone(struct task_struct *child,
  *
  * Called with no locks held, but the child cannot run until this returns.
  */
-static inline void tracehook_report_clone(int trace, struct pt_regs *regs,
+static inline void tracehook_report_clone(struct pt_regs *regs,
                                          unsigned long clone_flags,
                                          pid_t pid, struct task_struct *child)
 {
-       if (unlikely(trace) || unlikely(clone_flags & CLONE_PTRACE)) {
+       if (unlikely(task_ptrace(child))) {
                /*
-                * The child starts up with an immediate SIGSTOP.
+                * It doesn't matter who attached/attaching to this
+                * task, the pending SIGSTOP is right in any case.
                 */
                sigaddset(&child->pending.signal, SIGSTOP);
                set_tsk_thread_flag(child, TIF_SIGPENDING);
@@ -388,17 +387,14 @@ static inline void tracehook_signal_handler(int sig, siginfo_t *info,
  * tracehook_consider_ignored_signal - suppress short-circuit of ignored signal
  * @task:              task receiving the signal
  * @sig:               signal number being sent
- * @handler:           %SIG_IGN or %SIG_DFL
  *
  * Return zero iff tracing doesn't care to examine this ignored signal,
  * so it can short-circuit normal delivery and never even get queued.
- * Either @handler is %SIG_DFL and @sig's default is ignore, or it's %SIG_IGN.
  *
  * Called with @task->sighand->siglock held.
  */
 static inline int tracehook_consider_ignored_signal(struct task_struct *task,
-                                                   int sig,
-                                                   void __user *handler)
+                                                   int sig)
 {
        return (task_ptrace(task) & PT_PTRACED) != 0;
 }
@@ -407,19 +403,17 @@ static inline int tracehook_consider_ignored_signal(struct task_struct *task,
  * tracehook_consider_fatal_signal - suppress special handling of fatal signal
  * @task:              task receiving the signal
  * @sig:               signal number being sent
- * @handler:           %SIG_DFL or %SIG_IGN
  *
  * Return nonzero to prevent special handling of this termination signal.
- * Normally @handler is %SIG_DFL.  It can be %SIG_IGN if @sig is ignored,
- * in which case force_sig() is about to reset it to %SIG_DFL.
+ * Normally handler for signal is %SIG_DFL.  It can be %SIG_IGN if @sig is
+ * ignored, in which case force_sig() is about to reset it to %SIG_DFL.
  * When this returns zero, this signal might cause a quick termination
  * that does not give the debugger a chance to intercept the signal.
  *
  * Called with or without @task->sighand->siglock held.
  */
 static inline int tracehook_consider_fatal_signal(struct task_struct *task,
-                                                 int sig,
-                                                 void __user *handler)
+                                                 int sig)
 {
        return (task_ptrace(task) & PT_PTRACED) != 0;
 }
@@ -507,7 +501,7 @@ static inline int tracehook_notify_jctl(int notify, int why)
 static inline int tracehook_notify_death(struct task_struct *task,
                                         void **death_cookie, int group_dead)
 {
-       if (task->exit_signal == -1)
+       if (task_detached(task))
                return task->ptrace ? SIGCHLD : DEATH_REAP;
 
        /*