[PATCH 04/14] signal: don't notify parent if not stopping after tracehook_notify_jctl() in do_signal_stop()

From: Tejun Heo
Date: Fri Nov 26 2010 - 05:51:22 EST


do_signal_stop() tests sig->group_stop_count one more time after
calling tracehook_notify_jctl() as it's allowed release siglock. If
group_stop_count has changed to zero, it no longer stops but still
notifies the parent. For both SIGCONT and KILL which could cause the
condition, this notification is unnecessary.

SIGCONT will be notified to the parent when the task calls
get_signal_to_deliver() right after returning from do_signal_stop()
which will handle the collapsed notification correctly by itself. The
notification from do_signal_stop() in this case would only cause
duplication. For SIGKILL, the imminent death of the task will be
notified to parent and it's completely superflous to report the
skipped stop.

Also, tracehook_notify_jctl() doesn't release siglock, so, currently,
none of these matters at all.

This patch updates do_signal_stop() such that it jumps out of the
function if group_stop_count has dropped during
tracehook_notify_jctl().

This doesn't cause any behavior difference as the condition never
triggers in the current code.

Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
Cc: Oleg Nesterov <oleg@xxxxxxxxxx>
Cc: Roland McGrath <roland@xxxxxxxxxx>
---
kernel/signal.c | 21 +++++++++++++--------
1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 0a6816a..6f7407d 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1763,15 +1763,20 @@ static int do_signal_stop(int signr)
notify = tracehook_notify_jctl(notify, CLD_STOPPED);
/*
* tracehook_notify_jctl() can drop and reacquire siglock, so
- * we keep ->group_stop_count != 0 before the call. If SIGCONT
- * or SIGKILL comes in between ->group_stop_count == 0.
+ * we test ->group_stop_count again. If SIGCONT or SIGKILL
+ * comes in between, ->group_stop_count == 0.
*/
- if (sig->group_stop_count) {
- if (!--sig->group_stop_count)
- sig->flags = SIGNAL_STOP_STOPPED;
- current->exit_code = sig->group_exit_code;
- __set_current_state(TASK_STOPPED);
+ if (!sig->group_stop_count) {
+ spin_unlock_irq(&current->sighand->siglock);
+ goto out;
}
+
+ if (!--sig->group_stop_count)
+ sig->flags = SIGNAL_STOP_STOPPED;
+
+ current->exit_code = sig->group_exit_code;
+ __set_current_state(TASK_STOPPED);
+
spin_unlock_irq(&current->sighand->siglock);

if (notify) {
@@ -1782,7 +1787,7 @@ static int do_signal_stop(int signr)

/* Now we don't run again until woken by SIGCONT or SIGKILL */
schedule();
-
+out:
tracehook_finish_jctl();
current->exit_code = 0;

--
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/