__exit_signal() does flush_sigqueue(tsk->pending) outside of ->siglock.
This can race with another thread doing sigqueue_free(), we can free
the same SIGQUEUE_PREALLOC sigqueue twice or corrupt the pending->list.
Note that even sys_exit_group() can trigger this race, not only
sys_timer_delete().
Move the callsite of flush_sigqueue(tsk->pending) under ->siglock.
This patch doesn't touch flush_sigqueue(->shared_pending) below, it is
called when there are no other threads which can play with signals,
and sigqueue_free() can't be used outside of our thread group.
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
--- 25/kernel/exit.c~1_SF_EX_RACE 2008-03-20 18:25:11.000000000 +0300
+++ 25/kernel/exit.c 2008-05-03 18:21:34.000000000 +0400
@@ -125,6 +125,12 @@ static void __exit_signal(struct task_st
__unhash_process(tsk);
+ /*
+ * Do this under ->siglock, we can race with another thread
+ * doing sigqueue_free() if we have SIGQUEUE_PREALLOC signals.
+ */
+ flush_sigqueue(&tsk->pending);
+
tsk->signal = NULL;
tsk->sighand = NULL;
spin_unlock(&sighand->siglock);
@@ -132,7 +138,6 @@ static void __exit_signal(struct task_st
__cleanup_sighand(sighand);
clear_tsk_thread_flag(tsk,TIF_SIGPENDING);
- flush_sigqueue(&tsk->pending);
if (sig) {
flush_sigqueue(&sig->shared_pending);
taskstats_tgid_free(sig);
--- 25/kernel/signal.c~1_SF_EX_RACE 2008-05-03 17:47:01.000000000 +0400
+++ 25/kernel/signal.c 2008-05-03 18:27:03.000000000 +0400
@@ -1242,7 +1242,8 @@ void sigqueue_free(struct sigqueue *q)
/*
* If the signal is still pending remove it from the
* pending queue. We must hold ->siglock while testing
- * q->list to serialize with collect_signal().
+ * q->list to serialize with collect_signal() or with
+ * __exit_signal()->flush_sigqueue().
*/
spin_lock_irqsave(lock, flags);
if (!list_empty(&q->list))
--
| Ryan Hope | reiser4 for 2.6.27-rc1 |
| Ingo Molnar | Re: 2.6.24-rc6-mm1 |
| Tejun Heo | [PATCHSET] CUSE: implement CUSE |
| Peter Zijlstra | Re: 2.6.24-rc8-mm1 (BUG: sched_rt) |
git: | |
| Shawn O. Pearce | Re: [PATCH/POLL] git-format-patch: the default suffix is now .patch, not .txt |
| Jakub Narebski | Re: What's cooking in git.git (topics) |
| Junio C Hamano | Maintaining "needswork" section of "What's (not) cooking" |
| Matthias Lederhofer | [PATCH] prune-packed: new option --min-age=N |
| Theo de Raadt | That whole "Linux stealing our code" thing |
| Karthik Kumar | Re: Real men don't attack straw men |
| Khalid Schofield | Configuring sendmail openbsd 4.2 |
| Ray Percival | Re: Real men don't attack straw men |
| RW | Re: forcefsck on booting stage |
| Vladimir Terziev | Video memory as swap under FreeBSD |
| Ivan Voras | Progress for 7.0 - the "what's cooking" page |
| Pietro Cerutti | Re: [patch] enhance powerd(8) to handle max temperature |
