public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] Fix signal race during process exit
@ 2004-06-04  1:21 Roland McGrath
  2004-06-04  1:30 ` Andrew Morton
  0 siblings, 1 reply; 11+ messages in thread
From: Roland McGrath @ 2004-06-04  1:21 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux Kernel Mailing List

Is there a reproducer case around so we can test fixes for this problem?

It seems to me that signals sent to an already dying task might as well
just be discarded anyway.  All they ever do now (except for trip bugs) is
change what pending signals you see in the /proc/pid/status entry for a
zombie.  What's wrong with this:

Index: linux-2.6/kernel/signal.c
===================================================================
RCS file: /home/roland/redhat/bkcvs/linux-2.5/kernel/signal.c,v
retrieving revision 1.120
diff -u -b -p -r1.120 signal.c
--- linux-2.6/kernel/signal.c 10 May 2004 20:28:20 -0000 1.120
+++ linux-2.6/kernel/signal.c 4 Jun 2004 01:16:31 -0000
@@ -161,6 +161,9 @@ static int sig_ignored(struct task_struc
 {
 	void * handler;
 
+	if (t->flags & PF_DEAD)
+		return 1;
+
 	/*
 	 * Tracers always want to know about signals..
 	 */



Thanks,
Roland

^ permalink raw reply	[flat|nested] 11+ messages in thread
* [PATCH] Fix signal race during process exit
@ 2004-06-02  2:13 Jeremy Kerr
  2004-06-02  5:57 ` Andrew Morton
  0 siblings, 1 reply; 11+ messages in thread
From: Jeremy Kerr @ 2004-06-02  2:13 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

Andrew,

This patch fixes a race where timer-generated signals are delivered to an 
exiting process, after task->sighand is cleared.

update_one_process() declared static, as it is only used in kernel/timer.c

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>



Jeremy

diff -urN linux-2.6.7-rc2-bk2.orig/include/linux/sched.h 
linux-2.6.7-rc2-bk2/include/linux/sched.h
--- linux-2.6.7-rc2-bk2.orig/include/linux/sched.h	2004-06-02 
11:29:13.000000000 +1000
+++ linux-2.6.7-rc2-bk2/include/linux/sched.h	2004-06-02 11:46:57.000000000 
+1000
@@ -168,8 +168,6 @@
 extern void cpu_init (void);
 extern void trap_init(void);
 extern void update_process_times(int user);
-extern void update_one_process(struct task_struct *p, unsigned long user,
-			       unsigned long system, int cpu);
 extern void scheduler_tick(int user_tick, int system);
 extern unsigned long cache_decay_ticks;
 
Binary files linux-2.6.7-rc2-bk2.orig/kernel/.signal.c.swp and 
linux-2.6.7-rc2-bk2/kernel/.signal.c.swp differ
Binary files linux-2.6.7-rc2-bk2.orig/kernel/.timer.c.swp and 
linux-2.6.7-rc2-bk2/kernel/.timer.c.swp differ
diff -urN linux-2.6.7-rc2-bk2.orig/kernel/signal.c 
linux-2.6.7-rc2-bk2/kernel/signal.c
--- linux-2.6.7-rc2-bk2.orig/kernel/signal.c	2004-06-02 11:29:13.000000000 
+1000
+++ linux-2.6.7-rc2-bk2/kernel/signal.c	2004-06-02 11:47:28.000000000 +1000
@@ -323,7 +323,10 @@
 {
 	struct sighand_struct * sighand = tsk->sighand;
 
-	/* Ok, we're done with the signal handlers */
+	/* Ok, we're done with the signal handlers.
+	 * Set sighand to NULL to tell kernel/timer.c not
+	 * to deliver further signals to this task
+	 */
 	tsk->sighand = NULL;
 	if (atomic_dec_and_test(&sighand->count))
 		kmem_cache_free(sighand_cachep, sighand);
diff -urN linux-2.6.7-rc2-bk2.orig/kernel/timer.c 
linux-2.6.7-rc2-bk2/kernel/timer.c
--- linux-2.6.7-rc2-bk2.orig/kernel/timer.c	2004-06-02 11:29:13.000000000 
+1000
+++ linux-2.6.7-rc2-bk2/kernel/timer.c	2004-06-02 11:47:08.000000000 +1000
@@ -829,7 +829,7 @@
 	}
 }
 
-void update_one_process(struct task_struct *p, unsigned long user,
+static void update_one_process(struct task_struct *p, unsigned long user,
 			unsigned long system, int cpu)
 {
 	do_process_times(p, user, system);
@@ -846,7 +846,9 @@
 	struct task_struct *p = current;
 	int cpu = smp_processor_id(), system = user_tick ^ 1;
 
-	update_one_process(p, user_tick, system, cpu);
+	/* Don't send signals to current after release_task() */
+	if (likely(p->sighand)) 
+		update_one_process(p, user_tick, system, cpu);
 	run_local_timers();
 	scheduler_tick(user_tick, system);
 }




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

end of thread, other threads:[~2004-06-10  2:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-04  1:21 [PATCH] Fix signal race during process exit Roland McGrath
2004-06-04  1:30 ` Andrew Morton
2004-06-10  1:48   ` Roland McGrath
2004-06-10  2:20     ` Andrew Morton
2004-06-10  2:51     ` Rusty Russell
  -- strict thread matches above, loose matches on Subject: below --
2004-06-02  2:13 Jeremy Kerr
2004-06-02  5:57 ` Andrew Morton
2004-06-02  6:49   ` Rusty Russell
2004-06-02  7:08     ` Andrew Morton
2004-06-02  7:16       ` Andrew Morton
2004-06-02  8:13         ` Jeremy Kerr

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