diff options
author | Oleg Nesterov <oleg@redhat.com> | 2012-03-14 14:55:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-20 17:16:50 -0400 |
commit | 5f8aadd8b9966d71a77bba52b9d499cc2f38269f (patch) | |
tree | 229735d79edf0c4cc82ac00ba1abaee63040ff6e /kernel | |
parent | ed378a52dabf77b406b447fd3238f83ea24b71fa (diff) |
CLONE_PARENT shouldn't allow to set ->exit_signal
The child must not control its ->exit_signal, it is the parent who
decides which signal the child should use for notification.
This means that CLONE_PARENT should not use "clone_flags & CSIGNAL",
the forking task is the sibling of the new process and their parent
doesn't control exit_signal in this case.
This patch uses ->exit_signal of the forking process, but perhaps
we should simply use SIGCHLD.
We read group_leader->exit_signal lockless, this can race with the
ORIGINAL_SIGNAL -> SIGCHLD transition, but this is fine.
Potentially this change allows to kill self_exec_id/parent_exec_id.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/fork.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 26a7a6707fa7..c4f38a849436 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -1340,7 +1340,13 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1340 | clear_all_latency_tracing(p); | 1340 | clear_all_latency_tracing(p); |
1341 | 1341 | ||
1342 | /* ok, now we should be set up.. */ | 1342 | /* ok, now we should be set up.. */ |
1343 | p->exit_signal = (clone_flags & CLONE_THREAD) ? -1 : (clone_flags & CSIGNAL); | 1343 | if (clone_flags & CLONE_THREAD) |
1344 | p->exit_signal = -1; | ||
1345 | else if (clone_flags & CLONE_PARENT) | ||
1346 | p->exit_signal = current->group_leader->exit_signal; | ||
1347 | else | ||
1348 | p->exit_signal = (clone_flags & CSIGNAL); | ||
1349 | |||
1344 | p->pdeath_signal = 0; | 1350 | p->pdeath_signal = 0; |
1345 | p->exit_state = 0; | 1351 | p->exit_state = 0; |
1346 | 1352 | ||