summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2012-03-19 17:03:41 +0100
committerBen Hutchings <ben@decadent.org.uk>2012-05-11 13:15:04 +0100
commit82b8227228169ca4c3b138f6ad1171913c14f784 (patch)
tree590f4b0e1c27a228ac7c01c11628e37e6ad25511
parent3dc731904fb3bad1d3dbd8870cf4461fb2b31680 (diff)
exit_signal: fix the "parent has changed security domain" logic
commit b6e238dceed36891cc633167afe7151f1f3d83c5 upstream. exit_notify() changes ->exit_signal if the parent already did exec. This doesn't really work, we are not going to send the signal now if there is another live thread or the exiting task is traced. The parent can exec before the last dies or the tracer detaches. Move this check into do_notify_parent() which actually sends the signal. The user-visible change is that we do not change ->exit_signal, and thus the exiting task is still "clone children" for do_wait()->eligible_child(__WCLONE). Hopefully this is fine, the current logic is racy anyway. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--kernel/exit.c14
-rw-r--r--kernel/signal.c9
2 files changed, 9 insertions, 14 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index ab66cb051083..5a8a66ed650d 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -819,20 +819,6 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
if (group_dead)
kill_orphaned_pgrp(tsk->group_leader, NULL);
- /* Let father know we died
- *
- * Thread signals are configurable, but you aren't going to use
- * that to send signals to arbitrary processes.
- * That stops right now.
- *
- * If the parent exec id doesn't match the exec id we saved
- * when we started then we know the parent has changed security
- * domain.
- */
- if (thread_group_leader(tsk) && tsk->exit_signal != SIGCHLD &&
- tsk->parent_exec_id != tsk->real_parent->self_exec_id)
- tsk->exit_signal = SIGCHLD;
-
if (unlikely(tsk->ptrace)) {
int sig = thread_group_leader(tsk) &&
thread_group_empty(tsk) &&
diff --git a/kernel/signal.c b/kernel/signal.c
index 206551563cce..08e0b976eb8e 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1610,6 +1610,15 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
BUG_ON(!tsk->ptrace &&
(tsk->group_leader != tsk || !thread_group_empty(tsk)));
+ if (sig != SIGCHLD) {
+ /*
+ * This is only possible if parent == real_parent.
+ * Check if it has changed security domain.
+ */
+ if (tsk->parent_exec_id != tsk->parent->self_exec_id)
+ sig = SIGCHLD;
+ }
+
info.si_signo = sig;
info.si_errno = 0;
/*