public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] copy_process: fix CLONE_PARENT && ->exit_signal interaction
@ 2009-02-25 19:02 Oleg Nesterov
  2009-02-25 19:39 ` Roland McGrath
  0 siblings, 1 reply; 16+ messages in thread
From: Oleg Nesterov @ 2009-02-25 19:02 UTC (permalink / raw)
  To: Andrew Morton, Linus Torvalds
  Cc: Alan Cox, Chris Evans, David Howells, Don Howard, Eugene Teo,
	Michael Kerrisk, Roland McGrath, Tavis Ormandy, Vitaly Mayatskikh,
	stable, linux-kernel

clone(CLONE_PARENT | SIGXXX) blindly sets ->exit_signal = SIGXXX. It is not
clear to me what was the supposed behaviour but this does not look right.
The parent of the forking task will receive this signal which bypasses all
security checks.

With this patch CLONE_PARENT re-uses both ->real_parent and ->exit_signal,
this looks at least logical.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reported-by: Chris Evans <scarybeasts@gmail.com>

--- 6.29-rc3/kernel/fork.c~1_EXIT_SIGNAL	2009-02-09 01:03:48.000000000 +0100
+++ 6.29-rc3/kernel/fork.c	2009-02-25 18:09:56.000000000 +0100
@@ -1217,10 +1217,16 @@ static struct task_struct *copy_process(
 			!cpu_online(task_cpu(p))))
 		set_task_cpu(p, smp_processor_id());
 
-	/* CLONE_PARENT re-uses the old parent */
-	if (clone_flags & (CLONE_PARENT|CLONE_THREAD))
+	/* CLONE_PARENT re-uses the old parent and exit_signal */
+	if (clone_flags & (CLONE_PARENT|CLONE_THREAD)) {
+		/*
+		 * Do this under tasklist_lock to avoid the race with
+		 * re-parenting to init.
+		 */
+		if (!(clone_flags & CLONE_THREAD))
+			p->exit_signal = current->group_leader->exit_signal;
 		p->real_parent = current->real_parent;
-	else
+	} else
 		p->real_parent = current;
 
 	spin_lock(&current->sighand->siglock);


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2009-03-09 18:37 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-25 19:02 [PATCH 1/2] copy_process: fix CLONE_PARENT && ->exit_signal interaction Oleg Nesterov
2009-02-25 19:39 ` Roland McGrath
2009-02-25 19:48   ` Oleg Nesterov
2009-02-25 19:54     ` Roland McGrath
2009-02-25 20:06   ` Linus Torvalds
2009-02-25 21:20     ` Oleg Nesterov
2009-02-25 21:34       ` [stable] " Greg KH
2009-02-26 21:59       ` Oleg Nesterov
2009-02-26 22:12         ` Linus Torvalds
2009-02-26 22:30           ` Oleg Nesterov
2009-02-26 22:43             ` Linus Torvalds
2009-03-02 21:22             ` [PATCH] copy_process: fix CLONE_PARENT && parent_exec_id interaction Oleg Nesterov
2009-03-02 21:33               ` Linus Torvalds
2009-03-02 21:58                 ` Oleg Nesterov
2009-03-09 16:45                   ` David Howells
2009-03-09 18:33                     ` Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox