aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2008-07-25 22:45:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-26 15:00:09 -0400
commitfa00b80b3c41a845b3d56f866fb40a2e98754c51 (patch)
tree819d6966cad1fdeef3f32497c696afb203e3720b
parent7bcf6a2ca5f639b038c48711ebe6c4eca2036641 (diff)
tracehook: job control
This defines the tracehook_notify_jctl() hook to formalize the ptrace effects on the job control notifications. There is no change, only cleanup. Signed-off-by: Roland McGrath <roland@redhat.com> Cc: Oleg Nesterov <oleg@tv-sign.ru> Reviewed-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/tracehook.h20
-rw-r--r--kernel/signal.c10
2 files changed, 25 insertions, 5 deletions
diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
index 42a0d7b11959..6dc428dd2f38 100644
--- a/include/linux/tracehook.h
+++ b/include/linux/tracehook.h
@@ -451,4 +451,24 @@ static inline int tracehook_get_signal(struct task_struct *task,
451 return 0; 451 return 0;
452} 452}
453 453
454/**
455 * tracehook_notify_jctl - report about job control stop/continue
456 * @notify: nonzero if this is the last thread in the group to stop
457 * @why: %CLD_STOPPED or %CLD_CONTINUED
458 *
459 * This is called when we might call do_notify_parent_cldstop().
460 * It's called when about to stop for job control; we are already in
461 * %TASK_STOPPED state, about to call schedule(). It's also called when
462 * a delayed %CLD_STOPPED or %CLD_CONTINUED report is ready to be made.
463 *
464 * Return nonzero to generate a %SIGCHLD with @why, which is
465 * normal if @notify is nonzero.
466 *
467 * Called with no locks held.
468 */
469static inline int tracehook_notify_jctl(int notify, int why)
470{
471 return notify || (current->ptrace & PT_PTRACED);
472}
473
454#endif /* <linux/tracehook.h> */ 474#endif /* <linux/tracehook.h> */
diff --git a/kernel/signal.c b/kernel/signal.c
index 10b31ecdd9c8..e9e699f4b1bd 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -596,9 +596,6 @@ static int check_kill_permission(int sig, struct siginfo *info,
596 return security_task_kill(t, info, sig, 0); 596 return security_task_kill(t, info, sig, 0);
597} 597}
598 598
599/* forward decl */
600static void do_notify_parent_cldstop(struct task_struct *tsk, int why);
601
602/* 599/*
603 * Handle magic process-wide effects of stop/continue signals. Unlike 600 * Handle magic process-wide effects of stop/continue signals. Unlike
604 * the signal actions, these happen immediately at signal-generation 601 * the signal actions, these happen immediately at signal-generation
@@ -1605,7 +1602,7 @@ finish_stop(int stop_count)
1605 * a group stop in progress and we are the last to stop, 1602 * a group stop in progress and we are the last to stop,
1606 * report to the parent. When ptraced, every thread reports itself. 1603 * report to the parent. When ptraced, every thread reports itself.
1607 */ 1604 */
1608 if (stop_count == 0 || (current->ptrace & PT_PTRACED)) { 1605 if (tracehook_notify_jctl(stop_count == 0, CLD_STOPPED)) {
1609 read_lock(&tasklist_lock); 1606 read_lock(&tasklist_lock);
1610 do_notify_parent_cldstop(current, CLD_STOPPED); 1607 do_notify_parent_cldstop(current, CLD_STOPPED);
1611 read_unlock(&tasklist_lock); 1608 read_unlock(&tasklist_lock);
@@ -1741,6 +1738,9 @@ relock:
1741 signal->flags &= ~SIGNAL_CLD_MASK; 1738 signal->flags &= ~SIGNAL_CLD_MASK;
1742 spin_unlock_irq(&sighand->siglock); 1739 spin_unlock_irq(&sighand->siglock);
1743 1740
1741 if (unlikely(!tracehook_notify_jctl(1, why)))
1742 goto relock;
1743
1744 read_lock(&tasklist_lock); 1744 read_lock(&tasklist_lock);
1745 do_notify_parent_cldstop(current->group_leader, why); 1745 do_notify_parent_cldstop(current->group_leader, why);
1746 read_unlock(&tasklist_lock); 1746 read_unlock(&tasklist_lock);
@@ -1906,7 +1906,7 @@ void exit_signals(struct task_struct *tsk)
1906out: 1906out:
1907 spin_unlock_irq(&tsk->sighand->siglock); 1907 spin_unlock_irq(&tsk->sighand->siglock);
1908 1908
1909 if (unlikely(group_stop)) { 1909 if (unlikely(group_stop) && tracehook_notify_jctl(1, CLD_STOPPED)) {
1910 read_lock(&tasklist_lock); 1910 read_lock(&tasklist_lock);
1911 do_notify_parent_cldstop(tsk, CLD_STOPPED); 1911 do_notify_parent_cldstop(tsk, CLD_STOPPED);
1912 read_unlock(&tasklist_lock); 1912 read_unlock(&tasklist_lock);